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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
jeesan1234
Frequent Visitor

Power BI DAX formula to calculate difference between 2 columns

I have two tables:
1. Peer Review has columns Team, Reference (which is the policy ID), Banding and it also has other columns but this is the main table
2. Last week's data has columns, Team, Last week's premium I have joined the tables on the column Team.

I want to calculate the difference between count of the References that lie in where Banding is over 30 and last weeks premium in Power BI. 

I have tried the following formula:

 

Over 30 Mvt. 
IF(
ISBLANK(
CALCULATE(
COUNT('Peer Review'[Reference]),
FILTER('Peer Review', 'Peer Review'[Team_New] = 'Last week data'[Team])
)
),
0,
CALCULATE(((COUNT('Peer Review'[Reference])) - SUM('Last week data'[Last Week Over 30])), FILTER('Peer Review', 'Peer Review'[Banding] = "Over 30 Days"), FILTER('Peer Review', 'Peer Review'[Team_New] = 'Last week data'[Team]))
) 

 

And I have also tried creating a new measure just to calculate over 30 count reference but all of them are giving me the same results which are not correct:

TeamCount Over 30 DaysSum of Last Week Over 30Sum of Over 30 Mvt.
AAW 0 
Car612-6
CT550
En110
Ex330
Heal550
In56-1
IntD110
M4248-6
Mari350
Mar110
O 0 
Risk1011-1
PI101
P 0 
PB 01
Sp 0 
Fine Art657
Te13-2
Tre771
UK  0 
US 220
US232320
TOTAL131147-6
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi Kedar_Pande ,thanks for the quick reply, I'll add more.

Hi @jeesan1234 ,

but all of them are giving me the same results which are not correct

Do you mean the total row is incorrect?

vzhouwenmsft_0-1732501591386.png

 

Use the following DAX expression to create measures

Measure = 
VAR _result = 
CALCULATE(
COUNT('Peer Review'[Reference]),
'Peer Review'[Banding] = "Over 30"
)
RETURN
IF(ISBLANK(_result),0,_result)
Measure 2 = 
SUM('Last week data'[Last week's premium])
Measure 3 = 
VAR _table = SUMMARIZE('Last Week data',[Team],"Column1",[Measure],"Column2",[Measure 2],"Column3",ABS([Measure] - [Measure 2]))
RETURN SUMX(_table,[Column3])

If I understand you wrongly, please provide simple data and show the expected results in pictures.

 

Best Regards,
Wenbin Zhou

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi Kedar_Pande ,thanks for the quick reply, I'll add more.

Hi @jeesan1234 ,

but all of them are giving me the same results which are not correct

Do you mean the total row is incorrect?

vzhouwenmsft_0-1732501591386.png

 

Use the following DAX expression to create measures

Measure = 
VAR _result = 
CALCULATE(
COUNT('Peer Review'[Reference]),
'Peer Review'[Banding] = "Over 30"
)
RETURN
IF(ISBLANK(_result),0,_result)
Measure 2 = 
SUM('Last week data'[Last week's premium])
Measure 3 = 
VAR _table = SUMMARIZE('Last Week data',[Team],"Column1",[Measure],"Column2",[Measure 2],"Column3",ABS([Measure] - [Measure 2]))
RETURN SUMX(_table,[Column3])

If I understand you wrongly, please provide simple data and show the expected results in pictures.

 

Best Regards,
Wenbin Zhou

 

Kedar_Pande
Super User
Super User

@jeesan1234 

Create measures:

Count Over 30 = 
CALCULATE(
COUNT('Peer Review'[Reference]),
'Peer Review'[Banding] = "Over 30"
)
Last Week Premium = 
SUM('Last week data'[Last week's premium])
Over 30 Mvt = [Count Over 30] - [Last Week Premium]

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

Hi Kedar, thank you for getting back but the solution above gives me the exact same results, I am not sure why.

Helpful resources

Announcements
May PBI 25 Carousel

Power BI Monthly Update - May 2025

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

May 2025 Monthly Update

Fabric Community Update - May 2025

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