How to calculate an average of two fields in power pivot table?

astrbac

Board Regular
Joined
Jan 22, 2015
Messages
55
Hi all,

I have such a basic question that it pains me to even ask, but I just can't crack it. I use pivot tables extensively and have the following problem:

Source data:

DayCostRevenueReturn on investment
13000
11000
140020005
12300
150100020

<tbody>
</tbody>


Formula
Code:
Return on inv. = Revenue / Cost

The problem
If I draw a pivot table out of this dataset, It looks like this:

DaySum of Return on inv.Avg of Return on inv.
1255

<tbody>
</tbody>


The correct result - Average return on inv. for the whole day 1. is 5.84.
Code:
Total revenue/Total cost

How can I get the correct result in my pivot tables? It may be important to mention that I use "Get and transform" and power pivot so I cannot use "Calculated fields" in my pivot tables. All of the available fields are already loaded and transformed from .csv files.

Many thanks!
Alex
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Im no expert on these formulas but it will be something like:

ROItotal:=calculate(sum(Table1[Revenue])/sum(Table1[Cost]))

which should then appear as a field in the pivot table.
 
Upvote 0
Hi Steve,

thanks for taking the time to reply, much appreciated! Did you mean that I should use this formula that you wrote as a new "Calculated field" in my pivot table? If so, I'm afraid I will not be able to use that... My pivot tables are drawn as Power pivot (from Excels data model) and the option to create new calculated fields is greyed out and unclickable.

I have to do this in the "Transform" window where I write M language formulas. Thanks, I will investigate along these lines that you wrote

Cheers!
 
Upvote 0
Go to the table in power pivot. In one of the cells below the grey line place the formula. From the table create a pivot table. In that pivot you will have a new field.
 
Upvote 0
If you are using Power Pivot you need to create three new measures. One each for the SUM of cost and revenue and a third for SumRevenue/SumCost (although using DIVIDE would be better practice).
Peter

PS I think this is the same method Steve the Fish proposed but he suggested creating the measures in the calculation area of the Data Model. I usually write measures directly in the field list.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,554
Messages
6,114,280
Members
448,562
Latest member
Flashbond

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top