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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.