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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Wimverh
Resolver IV
Resolver IV

Subtotal is sum of division on a lower level

Hi,

 

I'm having problems to create the sum of the division on lower level. 
I have 2 calculations, on 2 different tables, linked to a general code (1 with a many tot many table in between)
On the lowest the results are fine, I try to calculate the value in red (this is the sum, of the rows in orange square)
Calculation should keep on working when filtering out products, or Groupcodes.
Subtotal_of_calculation.jpg
Following datamodel: 
Subtotal_of_calculation_dm.jpg
power bi file: https://wimv.be/forumpost/Subtotal_of_calculation.zip 

calculation of inventory Qty:

 

Inventory Qty = SUM([SalesQty])

 

calculation of Treshold Qty Rs:

 

Treshold Qty RS = if(HASONEVALUE(GeneralCode[GeneralCode]);
                    CALCULATE([Treshold Qty];FILTER(GeneralCode;[GeneralCode]<>[GeneralGroupCode]));
                    blank()
                    )

 

calculation of Treshold Evaluation TMP:

 

Treshold Evalulation TMP = 
if(HASONEVALUE(SevesoCode[SevesoGroupCode])
                            ;DIVIDE([Inventory Qty];[Treshold Qty RS]) 
                            ;blank()  // sum formula needed or in a seperate formula
                         )

 

 Best Regards, 

Wim

1 ACCEPTED SOLUTION

@Wimverh 

 

You may try the measure below.

Measure =
SUMX (
    VALUES ( GeneralCode[GeneralCode] ),
    DIVIDE (
        [Inventory Qty],
        [Treshold Qty RS]
    )
)

 

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

You are going to need to SUMMARIZE or GROUPBY and use the X functions across it. 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


@ 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...

Thx for Replying @Greg_Deckler 

I understand that I need to create a summarize table, and have a sumx on top. 
The problem is creating the summarized table in this specific setup with a many 2 many relation, 
when trying to create the summarized table, it's not giving values on row level.

Subtotal_of_calculation_formula.jpg

update file with summarized table: Subtotal_of_calculation_zipfile 

@Wimverh 

 

You may try the measure below.

Measure =
SUMX (
    VALUES ( GeneralCode[GeneralCode] ),
    DIVIDE (
        [Inventory Qty],
        [Treshold Qty RS]
    )
)

 

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.