In my Pivot table, I have a data field which I want to be summarized as count. I tried changing the subtotalfunction property to count, but it still shows the sum. Can someone give me an example of how I can do this?
In other words can anyone give me an example of a pivot table in which you can see the count and not the sum.
I’m using EPPlus latest build. 3.1.1
Thanks a lot 🙂
EDIT: This is what I’m trying.
var wsPivot = package.Workbook.Worksheets.Add("Pivot");
var pivotTable = wsPivot.PivotTables.Add(wsPivot.Cells["A55"], dataRange, "Table");
pivotTable.MultipleFieldFilters = true;
pivotTable.RowGrandTotals = true;
pivotTable.ColumGrandTotals = true;
pivotTable.Compact = true;
pivotTable.CompactData = true;
pivotTable.GridDropZones = false;
pivotTable.Outline = false;
pivotTable.OutlineData = false;
pivotTable.ShowError = true;
pivotTable.ErrorCaption = "[error]";
pivotTable.ShowHeaders = true;
pivotTable.UseAutoFormatting = true;
pivotTable.ApplyWidthHeightFormats = true;
pivotTable.ShowDrill = true;
pivotTable.FirstDataCol = 3;
pivotTable.RowHeaderCaption = "Caption";
var pageField = pivotTable.Fields["field1"];
pivotTable.PageFields.Add(pageField);
var rowField = pivotTable.Fields["cust"];
pivotTable.RowFields.Add(rowField);
var dataField = pivotTable.Fields["id"];
dataField.SubTotalFunctions = OfficeOpenXml.Table.PivotTable.eSubTotalFunctions.Count;
pivotTable.DataFields.Add(dataField);
I figured it out. This worked for me