# GrapeCity.Spreadsheet.PivotTables.IPivotTable.AddDataField

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="GrapeCity_Spreadsheet_PivotTables_IPivotTable_AddDataField_" data-uid="GrapeCity.Spreadsheet.PivotTables.IPivotTable.AddDataField*">AddDataField Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="GrapeCity_Spreadsheet_PivotTables_IPivotTable_AddDataField_" data-uid="GrapeCity.Spreadsheet.PivotTables.IPivotTable.AddDataField*"></a>
<h4 id="GrapeCity_Spreadsheet_PivotTables_IPivotTable_AddDataField_GrapeCity_Spreadsheet_PivotTables_IPivotField_System_String_GrapeCity_Spreadsheet_PivotTables_ConsolidationFunction_" data-uid="GrapeCity.Spreadsheet.PivotTables.IPivotTable.AddDataField(GrapeCity.Spreadsheet.PivotTables.IPivotField,System.String,GrapeCity.Spreadsheet.PivotTables.ConsolidationFunction)">AddDataField(IPivotField, string, ConsolidationFunction)</h4>
<div class="markdown level1 summary"><p>Adds a data field to a <a class="xref" href="GrapeCity.Spreadsheet.PivotTables.IPivotTable.html">IPivotTable</a> report.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">IPivotField AddDataField(IPivotField field, string caption = null, ConsolidationFunction function = ConsolidationFunction.Automatic)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Function AddDataField(field As IPivotField, Optional caption As String = Nothing, Optional [function] As ConsolidationFunction = ConsolidationFunction.Automatic) As IPivotField</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="GrapeCity.Spreadsheet.PivotTables.IPivotField.html">IPivotField</a></td>
      <td><span class="parametername">field</span></td>
      <td><p>The unique PivotTable field.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">caption</span></td>
      <td><p>The label used in the PivotTable report to identify this data field.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="GrapeCity.Spreadsheet.PivotTables.ConsolidationFunction.html">ConsolidationFunction</a></td>
      <td><span class="parametername">function</span></td>
      <td><p>The function performed in the added data field.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="GrapeCity.Spreadsheet.PivotTables.IPivotField.html">IPivotField</a></td>
      <td><p>Returns a <a class="xref" href="GrapeCity.Spreadsheet.PivotTables.IPivotField.html">IPivotField</a> object that represents the new data field.</p>
</td>
    </tr>
  </tbody>
</table>
</div>
