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
Peter_2020
Helper III
Helper III

SUM of displayed values

Hi all, 

 

I have a table with data imported from SQL server with Direct query where I have 3 column adjusted by filter and column „Standard time“ is calculated by formula:

Standard time = IF(Vyroba[Operation]="0020",0.42) & IF(Vyroba[Operation]="0030",0.53) & IF(Vyroba[Operation]="0040",1.0) & IF(Vyroba[Operation]="0080",2.92) & IF(Vyroba[Operation]="0090",21.5) & IF(Vyroba[Operation]="0110",7.33)

It looks like this:

PO NUMBEROPERATIONHOURSSTANDARD TIME
106035589401103,057,33
106035589501106,607,33
106035589600200,550,42
106035589600300,470,53
106035589600401,151,00
106035589600802,772,92
1060355896009020,9221,50
106035589700200,400,42
106035589700300,630,53
106035589700401,251,00
106035589700802,632,92
1060355897009020,9321,50
106035589701106,657,33
TOTAL 68,00 

 

It shows me the numbers which SUM is 74,7. But when I define to create SUM for column „Standard time“ it takes me this:

 

PO NUMBEROPERATIONHOURSSTANDARD TIME
106035589401103,0514,66
106035589501106,6036,65
106035589600200,550,42
106035589600300,471,06
106035589600401,152,00
106035589600802,775,84
1060355896009020,92258,00
106035589700200,400,42
106035589700300,631,06
106035589700401,252,00
106035589700802,638,76
1060355897009020,93365,50
106035589701106,6536,65
TOTAL 68,00733,02

 

It happens because I have defined that column „Hours“ gives me SUM of all numbers. When I turned off the SUM it gives me this:

 

PO NUMBEROPERATIONHOURSSTANDARD TIME
106035589401101,227,33
106035589401101,27,33
106035589501100,157,33
106035589501101,357,33
106035589501101,527,33
106035589501101,627,33
106035589501101,977,33
106035589600200,550,42
106035589600300,070,53
106035589600300,400,53
106035589600400,571,00
106035589600400,581,00
............
TOTAL  733,02

 

Question is how to get SUM of numbers which are shown on the table below in column "Standard time" (result 74,7):

 

PO NUMBEROPERATIONHOURSSTANDARD TIME
106035589401103,057,33
106035589501106,607,33
106035589600200,550,42
106035589600300,470,53
106035589600401,151,00
106035589600802,772,92
1060355896009020,9221,50
106035589700200,400,42
106035589700300,630,53
106035589700401,251,00
106035589700802,632,92
1060355897009020,9321,50
106035589701106,657,33
TOTAL 68,00 

 

Thanks for help!

P

1 ACCEPTED SOLUTION
v-zhenbw-msft
Community Support
Community Support

Hi @Peter_2020 ,

 

We can use two measures to meet your requirement.

 

1. Create a measure to assign a value to Operation.

 

Measure = 
SWITCH(
    TRUE(),
    MAX('Table'[OPERATION])="0110",7.33,
    MAX('Table'[OPERATION])="0020",0.42,
    MAX('Table'[OPERATION])="0030",0.53,
    MAX('Table'[OPERATION])="0040",1.1)

 

sum1.jpg

 

2. Then we can create a measure to get the result.

 

Standard time = SUMX(VALUES('Table'[PO NUMBER]),[Measure])

 

sum2.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

 

Best regards,

 

Community Support Team _ zhenbw

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


BTW, pbix as attached.

View solution in original post

6 REPLIES 6
v-zhenbw-msft
Community Support
Community Support

Hi @Peter_2020 ,

 

We can use two measures to meet your requirement.

 

1. Create a measure to assign a value to Operation.

 

Measure = 
SWITCH(
    TRUE(),
    MAX('Table'[OPERATION])="0110",7.33,
    MAX('Table'[OPERATION])="0020",0.42,
    MAX('Table'[OPERATION])="0030",0.53,
    MAX('Table'[OPERATION])="0040",1.1)

 

sum1.jpg

 

2. Then we can create a measure to get the result.

 

Standard time = SUMX(VALUES('Table'[PO NUMBER]),[Measure])

 

sum2.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

 

Best regards,

 

Community Support Team _ zhenbw

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


BTW, pbix as attached.

Hello, 

 

thank you for your help! this is exactly what I was looking for.

 

just small adjustment and it works:

 

SUMX(SUMMARIZE(Table,[PO NUMBER], Table[Operation]), Table[STANDARD TIME])

 

Thank you very much!

amitchandak
Super User
Super User

@Peter_2020 , Try like

sumx(values(Table[PO Number]),Table[STANDARD TIME])

Hi, you were not far. This works:

 

SUMX(SUMMARIZE(Table,[PO NUMBER], Table[Operation]), Table[STANDARD TIME])

Greg_Deckler
Super User
Super User

@Peter_2020 - Not sure I understand the issue. 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...

Dear Greg, thank you very much for very helpful information!

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.