Archive of Mr Excel Message Board
I have a VBA macro that produces a pivot table which shows these quantities by department.
I want to modify the pivot table to show each of the quantities times the unit price.
The following code runs:
PT.CalculatedFields.Add "DOrd", "=Price*Ord"
But to my surprise, the pivot table first adds up all the quantities for the department, then adds up all the prices for the department, then multiplies these sums together, producing a ridiculous result.
Is there any way to do this calculation correctly in the pivot table?
I realize I could add eight more fields to my table in excel and do the calculation before creating the pivot table.
Thanks in advance,
Bill

If your data set contained both the order quantity
and the sales amount and you could produce the
average price by department using a Calculated
Field.
