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

Special holiday offer! You and a friend can attend FabCon with a BOGO code. Supplies are limited. Register now.

Anonymous

Sorting Multiple Columns

Sorting or ranking fields should be one of the most common requirements in our daily work.  However, when we need to compare with multiple columns, it will not be suitable to use the rank function. Therefore, I would like to introduce a function that can help us meet our needs more easily.

 

Usage scenarios:

Sample data:

 

RicoZhou_0-1668650891225.png

 

Sort multiple columns with filter

Condition: Group, Quality ASC, Sales DESC and Group not equal to D

 

Formula:

 

formula=

COUNTROWS (

    FILTER (

        'Sample',

        ISONORAFTER (

                'Sample'[Group], SELECTEDVALUE ( 'Sample'[Group] ), ASC,

                'Sample'[Quality], MAX ( 'Sample'[Quality] ), ASC,

                'Sample'[Sales], SUM ( 'Sample'[Sales] ), DESC

        )

    )

)

 

 

Result: 

RicoZhou_1-1668650891230.png

 

Reference link:

Sorting by multiple columns - Microsoft Power BI Community

ISONORAFTER function (DAX) - DAX | Microsoft Learn

 

 

Author: Xiaoxin Sheng

Reviewer: Kerry Wang & Ula Huang