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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
nschmidt
Frequent Visitor

How do I use MIN or MINX to find the lowest value according to a filtered column

I have a sample data set below. How would I use a dax function to find the MIN of the rank column according to the part number. For example, I want to calculate the cost difference of the most recent rank which is 5 vs. the minimum rank. I can't just use the MIN function because it will automatically go to Rank 1. For part number 76554 I need the MIN function to look at the Rank column filtered down to the value in part number of 76554 and return 2 as my minimum rank.

 

Part NumberRankCost
4075631 $      1.25
4075632 $      1.25
4075633 $      1.25
4075634 $      1.25
4075635 $      1.35
765542 $      1.45
765543 $      1.55
765544 $      1.65
765545 $      1.00
990087663 $      1.00
990087664 $      1.00
990087665 $      1.10
1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@nschmidt 

Add this as a measure;

Variance = 
VAR _MinR = CALCULATE( min(Table9[Rank]), ALLEXCEPT(table9,Table9[Part Number]))
VAR _MaxR = CALCULATE( max(Table9[Rank]), ALLEXCEPT(table9,Table9[Part Number]))
return
CALCULATE( 
    MAX(Table9[Cost]),
    Table9[Rank] = _MaxR,
    ALLEXCEPT(table9,Table9[Part Number])
) - 
CALCULATE( 
    MAX(Table9[Cost]),
    Table9[Rank] = _MinR,
    ALLEXCEPT(table9,Table9[Part Number])
)

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

1 REPLY 1
Fowmy
Super User
Super User

@nschmidt 

Add this as a measure;

Variance = 
VAR _MinR = CALCULATE( min(Table9[Rank]), ALLEXCEPT(table9,Table9[Part Number]))
VAR _MaxR = CALCULATE( max(Table9[Rank]), ALLEXCEPT(table9,Table9[Part Number]))
return
CALCULATE( 
    MAX(Table9[Cost]),
    Table9[Rank] = _MaxR,
    ALLEXCEPT(table9,Table9[Part Number])
) - 
CALCULATE( 
    MAX(Table9[Cost]),
    Table9[Rank] = _MinR,
    ALLEXCEPT(table9,Table9[Part Number])
)

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.