Forum Discussion

julianst24's avatar
julianst24
Frequent Visitor
3 years ago
Solved

Need help with a Rank function in DAX

Hey guys, i need some help with a rank column in pbi. the situation is this: I need a column that ranks the last column (price) within each group of rows (defined by countrytier for rank globa...
  • v-jingzhang's avatar
    3 years ago

    Hi julianst24 

     

    Since one countrytier may have duplicated prices, we need to distinguish them when ranking. You can first add an Index column with Power Query Editor. Apply the change to the model. 

     

    Then create a calculated column with below code. It calculates the ranking based on the expression 'Table'[checking final price] + 'Table'[Index] * 0.000001.

    Rank =
    RANKX (
        FILTER (
            'Table',
            'Table'[countrytier for rank global]
                = EARLIER ( 'Table'[countrytier for rank global] )
        ),
        'Table'[checking final price] + 'Table'[Index] * 0.000001,
        ,
        ASC,
        DENSE
    )
    

     

    Best Regards,
    Community Support Team _ Jing
    If this post helps, please Accept it as Solution to help other members find it.