Forum Discussion

Nun's avatar
Nun
Resolver I
2 years ago
Solved

Rank DAX formula

Hello,

 

I have a table, created with 

ADDCOLUMNS(SUMMARIZECOLUMNS(Sales[Time Code],Sales[Custmer]),"Total Sales",[amountEUR]).
Time code field is linked to a calendar table where there is the same field Time code (each time code is a date)
The result is
Time Code Customer Total Sales 
3262715312,92
6562712334,53
72376511182,11
98376511115,84
2762711004,35
866279992,141
27659637,937
666279196,524
84297751,839
48657737,647
23257304,194
26747213,433

I would need to create a rank of the customer. Same customer has the same rank based on the total sales of all the time.

Thanks.

  • Hi Nun 

    you can achieve this by adding a calculated column to your table using the following DAX:

    rank = 
        RANKX( 
            ALL( table_name ), 
            CALCULATE( 
                SUM( table_name[Total Sales] ), 
                ALL( table_name ), 
                table_name[Customer] = EARLIER( table_name[Customer] ) 
            ), 
            , , DENSE
        )

    Please be aware of replacing "table_name" with the actual name of your table.

     

    If this answer helped you, please consider marking it as solution.

    Thank you!

    Cheers

    Tim

1 Reply

  • timalbers's avatar
    timalbers
    Skilled Sharer

    Hi Nun 

    you can achieve this by adding a calculated column to your table using the following DAX:

    rank = 
        RANKX( 
            ALL( table_name ), 
            CALCULATE( 
                SUM( table_name[Total Sales] ), 
                ALL( table_name ), 
                table_name[Customer] = EARLIER( table_name[Customer] ) 
            ), 
            , , DENSE
        )

    Please be aware of replacing "table_name" with the actual name of your table.

     

    If this answer helped you, please consider marking it as solution.

    Thank you!

    Cheers

    Tim