March 9, 2022
Hi everyone
With the rise in the price of steel in construction, it means a lot of clients are keen to see how their projects are being affected by this.
I would like to group totals under Headings, and then subtract these. Unfortunately I cannot see how to do this in a Pivot.
Has anyone got any ideas on how this can be achieved?
Thank you
Tom
Moderators
January 31, 2022
Moderators
January 31, 2022
Trusted Members
February 13, 2021
Trusted Members
February 13, 2021
No, I used Power Query, but I did have to load the queries to the data model, but that is all I did with the data model. If you open PQ you will see the tables I used; I created a running total column, grouped your original project costs together and merged that with the revised cost table then subtracted the running total column from the original total column to get the running difference and used the max to create the pivot table as that is the difference of the total revised and total original costs. As I said, the only thing I did was load the tables to the data model. I hope I'm making sense. You should be able to follow my steps in PQ, let me know if you have any questions.
The following users say thank you to Jessica Stewart for this useful post:
Philip TreacyModerators
January 31, 2022
March 9, 2022
Thank you Riny and Jessica for looking into this and apologies for the delay - I have been travelling to see my family overseas. I also had a bit of a think about what I was really wanting to achieve with my original query and have added a revised attachment.
What I was after was a Pivot that behaves a bit more flexibly when showing a differences column to allow deeper interrogation of cost differences.
Could you please let me know if a Pivot can behave like Desired_result_Pivot_1 and Desired_result_Pivot_2? You will notice that Allowance for furring channels is not captured in the Original_cost_estimate for example.
Moderators
January 31, 2022
Have a look at the attached file. Both Pivot tables can basically be the same. On one you collapse the Heading field. On the other you Expand the Heading field.
And to include any new lines from the Revised table, it's easiest to merge the Revised table (i.e. as the top table) with the Original (i.e. as the bottom table), LeftOuter.
Moderators
January 31, 2022
Moderators
January 31, 2022
Good morning Tom,
Okay, I see. Then you do two merges. First Original with Revised, Then Revised with Original. Append the two, remove duplicate descriptions, replace any null value in either of the cost columns with zero. Add a column for the difference and you are ready to go. See attached.
Although, this works, I feel it should be possible to this more intelligently. Though, I can't see it right now.
Riny
March 9, 2022
Hi Riny,
Thank you for this. This works very well, however, sum of the Pivoting functionality is lost when duplicates are removed. I'd like to have the ability to have duplicate descriptions in Original_cost_estimate and Revised_cost_estimate per the attached. Is this possible?
Tom
Moderators
January 31, 2022
Hi Tom,
To avoid the elimination of "General contingency" is easy. Just include the Heading column to the equation so that PQ looks for duplicates where both Heading and Description are the same.
The other issues doesn't seem to make much sense. Is this really goin to happen, I wonder? Why would you put 2 identical line items under the same heading. Common sense would suggest you enter 1 row for the Roof covering contingency for 2 items at 20000. but, if what you describe is a real life scenario, you would have to clean-up the tables first and group (summing) such identical rows before merging.
See attached.
Riny
March 9, 2022
Hi Riny
This is great thank you. I can't think of any more tweaks.
The other issues doesn't seem to make much sense. Is this really goin to happen, I wonder? Why would you put 2 identical line items under the same heading.
This is useful because sometimes I am working with unrefined data, so someone might have left a duplicate in the table and I would get caught out if I forgot to Pivot it myself. Your excel captures this request.
Tom
Moderators
January 31, 2022
Oh, but this is completely different. I focused on the desired pivot table and ignored the intermediate table as much of the information is not needed. Also took the liberty to clean-up the data table as it isn't best practice to use structured tables that include empty rows and columns and sub-headers withing the table. That made the PQ a lot easier.
See if this does what you need.
1 Guest(s)