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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

How to get DAX MIN (or MAX) value based on SORT BY COLUMN rule

Hi all,

 

Quite simple issue : I'm looking for a way to get MIN(columnA) knowing that column has been sorted by another columnB.

 

columnA data type = Text

 

Currently the MIN() function give me the minimum value with values beginning by "A"..

 

Thanks !

1 ACCEPTED SOLUTION

Multiple ways to do this. Easiest way is to find the min order and get the Word for the min order:

Min Word =
VAR MinOrder =
    MIN ( 'Table'[Order] )
RETURN
    CALCULATE ( MIN ( 'Table'[Words] ), 'Table'[Order] = MinOrder )

View solution in original post

4 REPLIES 4
v-jiascu-msft
Employee
Employee

Hi @Anonymous,

 

What's the expected result? Maybe share a sample too.

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Here is a data table :

Table.PNG

 

I sorted the column "Words" by the column "Order" :

Sorted.PNG

I'd like to get in DAX : MIN(Words) = "What" instead of "A".

 

I wonder if the DAX logic could respect the sort order I set previously.

Multiple ways to do this. Easiest way is to find the min order and get the Word for the min order:

Min Word =
VAR MinOrder =
    MIN ( 'Table'[Order] )
RETURN
    CALCULATE ( MIN ( 'Table'[Words] ), 'Table'[Order] = MinOrder )
Anonymous
Not applicable

Thanks !!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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