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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Nun
Resolver I
Resolver I

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.

1 ACCEPTED SOLUTION
timalbers
Super User
Super User

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


—————————————————————————————
✔️ If my answer helped you, please consider marking it as a solution.

View solution in original post

1 REPLY 1
timalbers
Super User
Super User

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


—————————————————————————————
✔️ If my answer helped you, please consider marking it as a solution.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.