How do you calculate a field from calculated fields.

alex1alex

Board Regular
Joined
Sep 12, 2014
Messages
57
Hello everyone,

I need to Aggregate a number of multiplications which are based on the Row and Columns. My best attempt at describing this is in pseudo-code.

Code:
[FONT=Calibri] 
[/FONT][FONT=Calibri]For each cell in the Pivot table[/FONT]
[FONT=Calibri]    SUM[/FONT]
[FONT=Calibri]       Foreach ORU [/FONT]
[FONT=Calibri]                  Percent= Look up the multiplier for that ORU associated with the Column[/FONT]
[FONT=Calibri]                  SUMofValue = Add all of the Values associated with that Column/Row combination[/FONT]
[FONT=Calibri]                  Multiply Percent * SUMofValue
[/FONT]

I tried a number of ways over the last few days and looked at loads of examples but am missing something.


I have an example XLS here from my onedrive: link
With some screen grabs below.
At the bottom is what I'd like the pivot table to look like.

Any help would really be appreciated.

Kind Regards,
Alex


2HC7Lk7.png


KK3b61v.png
 
Hi alex :)
This is very simple using Power Query.
Code:
let
    Charges = Excel.CurrentWorkbook(){[Name="Charges"]}[Content],
    SumByTypeAndORU = Table.Group(Charges, {"Type", "ORU"}, {{"SumType", each List.Sum([Value]), type number}}),
    Orubumgr = Excel.CurrentWorkbook(){[Name="ORUBUMGR"]}[Content],
    JoinTable = Table.NestedJoin(Orubumgr,{"ORU"},SumByTypeAndORU,{"ORU"},"New"),
    Expand = Table.ExpandTableColumn(JoinTable, "New", {"Type", "SumType"}, {"Type", "SumType"}),
    Result = Table.AddColumn(Expand, "Value", each [Percent]*[SumType])
in
    Result
You can add the result of PQ query to your data model or use directly in Pivot Table. You don't need to load the result into the sheet.

Regards
 
Upvote 0

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Hi Bill,

That is pretty cool. I hadn't thought about that approach even though I actually do something like this to create the Percent column in the ORUBUMGR table. :$

I didn't list it in my requirements (since it seemed to be getting too complex) but my Charges table has a bunch of other columns. If I do that 1st group table, I'll loose that ability to slice using those other columns. Also, the Charges table is pretty big ( a million + lines) so with those Join/Expand lines it'll be 100million lines.

ImkeF's solution is working really well/quickly so I'll stick with that.

Thanks very much though, I appreciate the help!
Alex
 
Upvote 0

Forum statistics

Threads
1,215,635
Messages
6,125,942
Members
449,275
Latest member
jacob_mcbride

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