Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
miaklarna
New Member

Total Sum of % calculations

Dear community,


I am stucked with the following question. I have 3 fact tables (they unfortunately cannot be merged to one table). I am performing a following actions to get a result for remote revenue based on remote volumes / total volumes * total revenue

 

Table Revenue:

 JanFebMarTotal
ProductA 57315
Product B1081028
 15151343

 

Table Volumes:

 

 JanFebMarTotal
ProductA10351257
Product B10163258
 205144115


Table remote Volumes:

 

 JanFebMarTotal
Product A415827
Product B481224
 8232051

 

The final table with the following dax gives the result that is not correct in total (both for rows and columns). 

 

 

remote_%_total_revenue = 
VAR remotevolumes = SUM('fact_remotevolumes'[volumes])
VAR totalvolumes = SUM('fact_volumes'[volumes])
VAR totalrevenue = SUM('fact_revenue'[revenue])
RETURN

totalrevenue * DIVIDE( remotevolumes, totalvolumes)

 

 

Output (please see in red correct total):

 

     Calculated Remote Revenue (% of total)
 JanFebMar  
Product A2,03,02,07,1Correct result: 7
Product B4,04,03,811,6Correct result: 11.8
 6,06,85,919,1 
 Correct result: 6Correct result: 7Correct result: 5.8Correct result: 18.8 

 

I applied following DAX. However the result is correct in total columns but still not correct for total rows and for grand total. The nested SUMXs did not help.

 

 

remote_revenue = 
CALCULATE(
    SUMX(
        'dim_products',
        [revenue] * [remote_%_total_volumes]
    ))

 

 

Output:

 

 JanFebMär  
Product A2,03,02,07,105263158Correct result: 7
Product B4,04,03,811,5862069Correct result: 11.8
 6,0 (it worked)7,0 (it worked)5,8 (it worked)19,06956522 
    Correct result: 18.8 


Does anyone have a hint what should be a solution for correct sum?

 

Thank you! 🙂

1 ACCEPTED SOLUTION
miaklarna
New Member

Thanks a lot for your help! I tried both solutions but it did not work for my data. 

 

Meanwhile I figured out why my nested SUMX did not work. Before going to the row context for month, I needed to summarize a table.  

 

I adjusted DAX a bit and it worked at the end.

 

Here is a DAX:

remote_revenue = 
    SUMX(
        'dim_products', SUMX(SUMMARIZE(dim_calendar, dim_calendar[MonthYearNum], "MonthYear", dim_calendar[MonthYearNum]),
        [revenue_total] * [remote_%_total_volumes]))

 

 

View solution in original post

3 REPLIES 3
miaklarna
New Member

Thanks a lot for your help! I tried both solutions but it did not work for my data. 

 

Meanwhile I figured out why my nested SUMX did not work. Before going to the row context for month, I needed to summarize a table.  

 

I adjusted DAX a bit and it worked at the end.

 

Here is a DAX:

remote_revenue = 
    SUMX(
        'dim_products', SUMX(SUMMARIZE(dim_calendar, dim_calendar[MonthYearNum], "MonthYear", dim_calendar[MonthYearNum]),
        [revenue_total] * [remote_%_total_volumes]))

 

 

v-heq-msft
Community Support
Community Support

Hi @miaklarna ,

Here some steps that I want to share, you can check them if they suitable for your requirement.

Here is my test data:
fact_remotevolumes

vheqmsft_0-1707294872424.png
fact_revenue

vheqmsft_1-1707294897630.png

fact_volumes

vheqmsft_2-1707294968731.png

Open Power query and select custom column

vheqmsft_3-1707295096375.png

vheqmsft_4-1707295111780.png
Create calculate column

Column = 'fact_remotevolumes'[volumes] / RELATED(fact_volumes[volumes]) * RELATED(fact_revenue[revenue])

 

vheqmsft_7-1707295280337.png

 

Final output

vheqmsft_6-1707295257046.png

 

vheqmsft_5-1707295224640.png

 

Best regards

Albert He

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 



 

 

Greg_Deckler
Super User
Super User

@miaklarna First, please vote for this idea: https://ideas.powerbi.com/ideas/idea/?ideaid=082203f1-594f-4ba7-ac87-bb91096c742e

This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

Also: https://youtu.be/uXRriTN0cfY
And: https://youtu.be/n4TYhF2ARe8


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.