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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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

Hi @Anonymous ,

 

Please try this:

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

Aiolos Zhao

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

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

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

Anonymous
Not applicable

Hi @Anonymous ,

 

Please try this:

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

Aiolos Zhao

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!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.