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
Anonymous
Not applicable

Evaluate an expression across a group in power bi desktop

Hi All,

 

Looking for suggestions to evaluate an expression e.g. Sum(A minus B) for Country, where the value will be the same across quarters:

 

QuarterCountryAB
Q1Japan18721835
Q2India335726
Q2Japan586871
Q1USA12351903
Q3India7101935
Q1Germany12741327
Q2USA1647531

 

For the above example, the value should be:

Q1Japan-248
Q2India-1616
Q2Japan-248
Q1USA448
Q3India-1616
Q1Germany-53
Q2USA448

 

For Japan, Sum(A) = 2,458 and Sum(B) = 2,706.. and thus Sum(A-B) = -248

(The value will be same if each row is evaluated for A-B and then the final Sum is calculated)

 

Thanks in advance! 🙂

 

 

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

Please try this:

Measure = CALCULATE(SUM('Table'[A]) - SUM('Table'[B]),ALLEXCEPT('Table','Table'[Country]))

Aiolos Zhao





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
AiolosZhao
Memorable Member
Memorable Member

Hi @Anonymous ,

 

You can use below measure directly:

Measure = SUM('Table'[   A]) - SUM('Table'[   B])

Evaluate an expression across a group in power bi desktop.PNG

 

Aiolos Zhao





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Hi AiolosZhao,

 

Edited the question.. Need to get the same value for country irrespective of other columns.

Have taken Quarter as an example, could be more than that

Hi @Anonymous ,

 

Please try this:

Measure = CALCULATE(SUM('Table'[A]) - SUM('Table'[B]),ALLEXCEPT('Table','Table'[Country]))

Aiolos Zhao





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.