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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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