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
Hyperchef1969
Helper V
Helper V

Summarize multiple variables

Hi,

 

I need to calculate the standard hours per MFG_ORDER_NAME. This calculated value per individual line is OK, but the sum is incorrect. I tried summarize function but I need help ons this.

 

For HRS_STANDARD I calculated two variables, insteltijd and produktietijd. When I add those two at the return function, the calculation at line level is correct, however the total is incorrect. I tried SUMX(SUMMARIZE but I cannot select the two calculated variables when doing so. Can anyone help with the correct syntax?

 

Import_machining_res_transactions - Power BI Desktop_2018-11-23_11-29-39.png

1 ACCEPTED SOLUTION

I would probably go with something like:

 

Measure Total =
VAR __table = SUMMARIZE('Table',[MFG_ORDER_NAME],[DEPARTMENT],[BASIS],"__hrsStandard",[HRS STANDARD])
VAR __total = SUMX(__table,[__hrsStandard])
RETURN
IF(HASONEVALUE([DEPARTMENT]),[HRS STANDARD],__total)

You may have to modify the SUMMARIZE.


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

View solution in original post

9 REPLIES 9
Ashish_Mathur
Super User
Super User

Hi,

 

Write this additional measure and drag this to the Table visual

 

=IF(HASONEVALUE(MFG_ORDER_NAME),[HRS_STANDARD],SUMX(SUMMARIZE(VALUES([MFG_ORDER_NAME]),[MFG_ORDER_NAME],"ABCD",[HRS_STANDARD]),[ABCD]))

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish,

 

Tried following extra measure and dragged it into the visual. Still total is incorrect

 

Import_machining_res_transactions - Power BI Desktop_2018-11-30_11-24-15.png

Hi,

 

Share the link from where i can download your PBI file.  Also, show the expected result in a tet box there.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Greg,

 

Your solution summarizes also 4.5 hours instead of 32.85 (See measure total).

 

For the PBix file see: https://drive.google.com/open?id=13X8wROZ0tyUlwI3uahNAZK_Y0u7EtVSy

 

Import_machining_res_transactions - Power BI Desktop_2018-11-30_16-12-19.png

Hi Ashish,

 

Hereby the link and expected result. I rebuild the Power BI file to a document based on excel. The original file is a file based on direct query on our data warehouse which I cannot share with underlying data.

 

This is the link: https://drive.google.com/open?id=13X8wROZ0tyUlwI3uahNAZK_Y0u7EtVSy

Greg_Deckler
Super User
Super User

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

Thanks for your reply. I read your articles. Can you show how my calculation should look like?

I would probably go with something like:

 

Measure Total =
VAR __table = SUMMARIZE('Table',[MFG_ORDER_NAME],[DEPARTMENT],[BASIS],"__hrsStandard",[HRS STANDARD])
VAR __total = SUMX(__table,[__hrsStandard])
RETURN
IF(HASONEVALUE([DEPARTMENT]),[HRS STANDARD],__total)

You may have to modify the SUMMARIZE.


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