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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Finding the difference between values in the same column depending on another column.

Hi,

 

I am looking to find the difference between each of company 1's rate and the max of the rest of the companies rates for each year. A simplified version of the data may look something like this. 

 

YearCompanyRate
20181

0.02

201910.023
201820.01
201920.018
201830.011
201930.012

 

My aim is to draw a line graph representing the market margin between company 1 (always the highest rate) and the rest of the market for each year. So in the simplied version for 2018 the margin would be 0.02 - 0.011 - 0.009. 

 

I'm unsure of how to do this in DAX. I imagine that the Filter function is used but I cannot seem to get the filter function to work inside a MAX function.  

 

Thanks for your time,

Sean. 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Picture1.png

 

Expected result : =
VAR currentyear =
MAX ( data[Year] )
VAR companyonerate =
CALCULATE (
SUM ( data[Rate] ),
FILTER ( ALL ( data ), data[Year] = currentyear && data[Company] = 1 )
)
VAR othersmax =
MAXX ( FILTER ( data, data[Company] <> 1 ), data[Rate] )
RETURN
IF ( HASONEVALUE ( data[Year] ), companyonerate - othersmax )
 
 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Picture1.png

 

Expected result : =
VAR currentyear =
MAX ( data[Year] )
VAR companyonerate =
CALCULATE (
SUM ( data[Rate] ),
FILTER ( ALL ( data ), data[Year] = currentyear && data[Company] = 1 )
)
VAR othersmax =
MAXX ( FILTER ( data, data[Company] <> 1 ), data[Rate] )
RETURN
IF ( HASONEVALUE ( data[Year] ), companyonerate - othersmax )
 
 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
amitchandak
Super User
Super User

@Anonymous , Based on what I got

 

calculate(max(Table[Rate]) -Min(Table[Rate]) , allexcept(Table, Table[Year]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors