Forum Discussion

AlexanderK's avatar
AlexanderK
Frequent Visitor
5 years ago
Solved

RANKX in total row

Hi!

Can anyone help me with the RANKX. How to use the rank result for "My product" as a total row value (6 instead of 1)

 

My formula is Rank = RANKX(ALL('Table'[Level 2]),CALCULATE(SUM('Table'[Sum])))

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi AlexanderK ,

     

    Try this measure

    Rank =
    VAR tt =
        RANKX ( ALL ( 'Table' ), CALCULATE ( SUM ( 'Table'[Value] ) ) )
    VAR _tt =
        ADDCOLUMNS (
            'Table',
            "rank", RANKX ( ALL ( 'Table' ), CALCULATE ( SUM ( 'Table'[Value] ) ) )
        )
    RETURN
        IF (
            HASONEVALUE ( 'Table'[Product] ),
            tt,
            MAXX ( FILTER ( _tt, [Product] = "My product" ), [rank] )
        )

     

    You can check more details from here.

     

     

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi AlexanderK ,

     

    Try this measure

    Rank =
    VAR tt =
        RANKX ( ALL ( 'Table' ), CALCULATE ( SUM ( 'Table'[Value] ) ) )
    VAR _tt =
        ADDCOLUMNS (
            'Table',
            "rank", RANKX ( ALL ( 'Table' ), CALCULATE ( SUM ( 'Table'[Value] ) ) )
        )
    RETURN
        IF (
            HASONEVALUE ( 'Table'[Product] ),
            tt,
            MAXX ( FILTER ( _tt, [Product] = "My product" ), [rank] )
        )

     

    You can check more details from here.

     

     

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.