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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register 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
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.