B
bren
In runtime, if the toolbar is enabled, the user can add a total by
opening the "Pivot Table Field List" and dragging a "Totals" field from
the list window and dropping it on the pivot table.
I want to do this in code before the pivot table is displayed.
Data for my pivot table comes from an MDX query string assigned to the
CommandText property of the pivot table.
In the MDX query, I have three measures defined ON COLUMNS, but only
one of them is being displayed. I can't see how to configure another to
display in Design Time, so I'm trying to do it in code.
There is an InsertTotal method on the PivotView object. It uses an
AddTotal method on the same PivotView object.
I can't figure out from which FieldSet to get my Field to use as the
second parameter of the AddTotal method. How would I reference in code
the "Pivot Table Field List" > "Totals" > "Total Cost" field?
Here's my attempt, but I'm getting an "Invalid number of arguments"
exception.
oView = AxPivotTable1.ActiveView
oTotal = oView.AddTotal("Total Cost",
oView.FieldSets("Totals").Fields("Total Cost"),
PivotTotalFunctionEnum.plFunctionSum)
I think I'm getting close to an answer; maybe a friendly push will get
me going.
Thanks, Bren
opening the "Pivot Table Field List" and dragging a "Totals" field from
the list window and dropping it on the pivot table.
I want to do this in code before the pivot table is displayed.
Data for my pivot table comes from an MDX query string assigned to the
CommandText property of the pivot table.
In the MDX query, I have three measures defined ON COLUMNS, but only
one of them is being displayed. I can't see how to configure another to
display in Design Time, so I'm trying to do it in code.
There is an InsertTotal method on the PivotView object. It uses an
AddTotal method on the same PivotView object.
I can't figure out from which FieldSet to get my Field to use as the
second parameter of the AddTotal method. How would I reference in code
the "Pivot Table Field List" > "Totals" > "Total Cost" field?
Here's my attempt, but I'm getting an "Invalid number of arguments"
exception.
oView = AxPivotTable1.ActiveView
oTotal = oView.AddTotal("Total Cost",
oView.FieldSets("Totals").Fields("Total Cost"),
PivotTotalFunctionEnum.plFunctionSum)
I think I'm getting close to an answer; maybe a friendly push will get
me going.
Thanks, Bren