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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Anonymous
Not applicable

Calculate the sum of a measure

Hello

I need a way to calculate the sum of a measure.

I have two tables (A, B) with the same columns (ID and price) and I need to check if the information in both tables is the same. I have made a report with these characteristics:

- Rows: ID (A)

- Values: price (A), ID (B), price (B), price difference (a measure with the difference between price(A) and price (B)) and difference (a measure that is 0 if the difference is 0 and 1 in another case)

I need to have another measure with the sum of the measurement difference to show it in a target. I've tried using sum, sumx, count,... but they all work with a column, not a measurement.

Could you help me please?

Thank you!

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

Hi @Anonymous ,

 

Please try the following measure:

 

SumScoreMeasure = 
SUMX ( ALLSELECTED ( 'Table(A)'[ID(A)] ), [difference] )

vkkfmsft_0-1653983399769.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
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
v-kkf-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try the following measure:

 

SumScoreMeasure = 
SUMX ( ALLSELECTED ( 'Table(A)'[ID(A)] ), [difference] )

vkkfmsft_0-1653983399769.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
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

@Anonymous This looks like a measure aggregation problem. See my blog article about that here: https://community.powerbi.com/t5/Community-Blog/Design-Pattern-Groups-and-Super-Groups/ba-p/138149

The pattern is:
MinScoreMeasure = MINX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
MaxScoreMeasure = MAXX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
AvgScoreMeasure = AVERAGEX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
etc.



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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hello @Greg_Deckler ,

 

Thank you for the information. I have tried to define the measures you comment but something it's wrong, as it returns a 0.

I have defined the measures like this:

   MinScoreMeasure = MINX(SUMMARIZE(Table(A),ID(A),"Measure", [difference ] ), [difference ])

   MaxScoreMeasure = MAXX(SUMMARIZE(Table(A),ID(A),"Measure", [difference ] ), [difference ])

   AvgScoreMeasure = AVERAGEX(SUMMARIZE(Table(A),ID(A),"Measure", [difference ] ), [difference ])

Where difference is a calculated measure that is 0 if the difference between price(A) and price(B) is 0 and 1 in another case.

Thanks!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Kudoed Authors