Forum Discussion
Nun
2 years agoResolver 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
| 32 | 627 | 15312,92 |
| 65 | 627 | 12334,53 |
| 72 | 3765 | 11182,11 |
| 98 | 3765 | 11115,84 |
| 27 | 627 | 11004,35 |
| 86 | 627 | 9992,141 |
| 27 | 65 | 9637,937 |
| 66 | 627 | 9196,524 |
| 84 | 29 | 7751,839 |
| 48 | 65 | 7737,647 |
| 23 | 25 | 7304,194 |
| 26 | 74 | 7213,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!
CheersTim
1 Reply
- timalbersSkilled 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!
CheersTim