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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
Anonymous
Not applicable

Conditional difference based on conditional values

Below is my data

 

Capture.PNG

 

What I'm trying to get is the cost difference from the rank 1 carrier against lines that don't have a rank.  So for line 2, it would calculate 150 - 100, and line 5 would calculate 900 - 100. My data would look like.

Capture2.PNG

 

Alternatively, it can look like this since I can filter out the non-blanks

 

Capture3.PNG

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Try as a new column

 

new column =
var _min = minx(filter(Table, [lane] =earlier([lane]) && [Rank]=1),[Cost])
return
if(isblank([RANK]) || [RANK]<>1 , [Cost] -_min, blank())

 

Or

 

new column =
var _min = minx(filter(Table, [lane] =earlier([lane]) && [Rank]=1),[Cost])
return
if(isblank([RANK])  , [Cost] -_min, blank())

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

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Anonymous,

I think the above expressions are suitable for your requirement. If they meet your requirement, you can consider accepting these as a solution to help others who have similar requirements to find it more quickly.

If not, you can feel free to post here with detailed descriptions.

Regards,
Xiaoxin Sheng

amitchandak
Super User
Super User

@Anonymous , Try as a new column

 

new column =
var _min = minx(filter(Table, [lane] =earlier([lane]) && [Rank]=1),[Cost])
return
if(isblank([RANK]) || [RANK]<>1 , [Cost] -_min, blank())

 

Or

 

new column =
var _min = minx(filter(Table, [lane] =earlier([lane]) && [Rank]=1),[Cost])
return
if(isblank([RANK])  , [Cost] -_min, blank())

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
AlB
Community Champion
Community Champion

Hi @Anonymous

 

Cost from non-rank =
VAR rank1Cost_ =
    CALCULATE (
        DISTINCT ( Table1[Cost] ),
        Table1[Rank] = 1,
        ALLEXCEPT ( Table1, Table1[Lane] )
    )
RETURN
    IF ( NOT Table1[Rank] IN { 1, BLANK () }, Table1[Cost] - rank1Cost_ )

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors