Forum Discussion

Luukvv93's avatar
Luukvv93
Icon for Helper II rankHelper II
7 years ago
Solved

Need help with ranking measure

Hello community,   I have 3 measures from which I only want to show the top 3 values and the bottom 3 values in the same column for the respective measure.   S-ratio = MAX(DataUnpivot[Solvabilite...
  • Mariusz's avatar
    7 years ago

    Hi Luukvv93 

    To receive below result.

     

     

    You can modify below DAX expression. 

     

    Rank Top and Bottom Three Sales by Brand =
    VAR __grain =
        CALCULATETABLE (
            VALUES ( 'Product'[Brand] ),
            --Rank by Column 
            ALLSELECTED ()
        ) -- replace [Sales] with your Measure
    VAR __top =
        RANKX ( __grain, [Sales],, DESC ) <= 3
    VAR __bottom =
        RANKX ( __grain, [Sales],, ASC ) <= 3
    RETURN
        SWITCH ( TRUE (), __top, [Sales], __bottom, [Sales] )

     

     

    Best Regards,
    Mariusz

    If this post helps, then please consider Accepting it as the solution.

    Please feel free to connect with me.
    LinkedIn