Adding multiple display names based on the same data field

Hello


Am trying to add two display names (one for the Count and the other the Sum function) using the same pivot data field. At present only the first display name i.e. “Tally 1” is shown. What might be the issue? The following is the code snippet:

//Add pivot’s data field
pivotTable.AddFieldToArea(Aspose.Cells.Pivot.PivotFieldType.Data, 6);

//Add multiple display names for the data field (using Count and Sum functions)
pivotTable.DataFields[0].Function = ConsolidationFunction.Count;
pivotTable.DataFields[0].DisplayName = “Tally 1”;

pivotTable.DataFields[0].Function = ConsolidationFunction.Sum;
pivotTable.DataFields[0].DisplayName = “Tally 2”;


Thanks

Hi,


I think you may change your code segment to:
e.g
Sample code:

//Add pivot’s data field
pivotTable.AddFieldToArea(Aspose.Cells.Pivot.PivotFieldType.Data, 6);
pivotTable.AddFieldToArea(Aspose.Cells.Pivot.PivotFieldType.Data, 6);

//Add multiple display names for the data field (using Count and Sum functions)
pivotTable.DataFields[0].Function = ConsolidationFunction.Count;
pivotTable.DataFields[0].DisplayName = “Tally 1”;

pivotTable.DataFields[1].Function = ConsolidationFunction.Sum;
pivotTable.DataFields[1].DisplayName = “Tally 2”;

Hope, this helps a bit.

Thank you.