I'm using the below code block to pass in a pivot table along with some settings to loop through the measures and add differences where needed. The output is dropping the totals. Grand total, column total and row total are all returning null. Is there a config setting I am missing?
private static IPivotTable getDiffPivotTable(IPivotTable pvtTbl, List<bool> showDifference, List<bool> isPercent, List<string> direction)
{
DifferencePivotTable diffPvt;
IPivotTable output = pvtTbl;
for (int i = 0; i < showDifference.Count; i++)
{
if (showDifference[i])
{
switch (direction[i])
{
case "previousRow":
{
diffPvt = new DifferencePivotTable(
pvtTbl,
DifferencePivotTable.DifferenceMode.PreviousRow,
i);
diffPvt.Percentage = isPercent[i];
output = diffPvt;
break;
}
case "nextRow":
{
diffPvt = new DifferencePivotTable(
pvtTbl,
DifferencePivotTable.DifferenceMode.NextRow,
i);
diffPvt.Percentage = isPercent[i];
output = diffPvt;
break;
}
case "previousColumn":
{
diffPvt = new DifferencePivotTable(
pvtTbl,
DifferencePivotTable.DifferenceMode.PreviousColumn,
i);
diffPvt.Percentage = isPercent[i];
output = diffPvt;
break;
}
case "nextColumn":
{
diffPvt = new DifferencePivotTable(
pvtTbl,
DifferencePivotTable.DifferenceMode.NextColumn,
i);
diffPvt.Percentage = isPercent[i];
output = diffPvt;
break;
}
default:
{
Console.WriteLine("Difference type not supported");
return output;
}
}
}
}
return output;
}