Forum Discussion
Anonymous
4 years agoNot applicable
DAX: Ranking a measure based on a Column
Hello All, I am trying to create ranking of sales by customers and customer groups. Now these customers are been grouped as tier 1 and tier2. But in visualization I am using only Customer co...
- 4 years ago
Hi, Anonymous ;
Try it.
Total Sales = CALCULATE(SUM('Table'[Sales]),FILTER(ALLSELECTED('Table'),[Customer Group]=MAX('Table'[Customer Group])&&[Customer]=MAX('Table'[Customer])))Top 5 Customers = RANKX( FILTER( ALL('Table'),[Tier1/2]=MAX('Table'[Tier1/2])), CALCULATE( [Total Sales]) ,, DESC,Dense)The final show:
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
4 years agoSuper User
Anonymous Try if the two measures can help
M1= CALCULATE(SUM('Table'[Sales]),,filter(allseleced('Table'),'Table'[Customer] = max('Table'[Customer]) && 'Table'[Customer Group] =max('Table'[Customer Group] )))
Top 5 Customers =
RANKX(
ALL('Table'[Customer],'Table'[Customer Group], 'Table'[Date]),
[M1]
,,
DESC
)
Anonymous
4 years agoNot applicable
amitchandak below is the expected result that i am looking for.
Please help.
| Begin of Week | Customer | Total Sales | Top 5 | Expected Ranking | Rule |
| 03-01-2022 | C1 | 8615 | 10 | 5 | Part of Tier1 customegroup |
| 10-01-2022 | C1 | 8615 | 10 | 5 | Part of Tier1 customegroup |
| 17-01-2022 | C1 | 8615 | 10 | 5 | Part of Tier1 customegroup |
| 24-01-2022 | C1 | 8615 | 10 | 5 | Part of Tier1 customegroup |
| 31-01-2022 | C1 | 8615 | 10 | 5 | Part of Tier1 customegroup |
| 03-01-2022 | C2 | 9918 | 9 | 4 | Part of Tier1 customegroup |
| 10-01-2022 | C2 | 9918 | 9 | 4 | Part of Tier1 customegroup |
| 17-01-2022 | C2 | 9918 | 9 | 4 | Part of Tier1 customegroup |
| 24-01-2022 | C2 | 9918 | 9 | 4 | Part of Tier1 customegroup |
| 31-01-2022 | C2 | 9918 | 9 | 4 | Part of Tier1 customegroup |
| 03-01-2022 | C5 | 10362 | 8 | 3 | Part of Tier1 customegroup |
| 10-01-2022 | C5 | 10362 | 8 | 3 | Part of Tier1 customegroup |
| 17-01-2022 | C5 | 10362 | 8 | 3 | Part of Tier1 customegroup |
| 24-01-2022 | C5 | 10362 | 8 | 3 | Part of Tier1 customegroup |
| 31-01-2022 | C5 | 10362 | 8 | 3 | Part of Tier1 customegroup |
| 03-01-2022 | C9 | 10781 | 7 | 5 | Part of Tier2 customegroup |
| 10-01-2022 | C9 | 10781 | 7 | 5 | Part of Tier2 customegroup |
| 17-01-2022 | C9 | 10781 | 7 | 5 | Part of Tier2 customegroup |
| 24-01-2022 | C9 | 10781 | 7 | 5 | Part of Tier2 customegroup |
| 31-01-2022 | C9 | 10781 | 7 | 5 | Part of Tier2 customegroup |
| 03-01-2022 | C4 | 10812 | 6 | 2 | Part of Tier1 customegroup |
| 10-01-2022 | C4 | 10812 | 6 | 2 | Part of Tier1 customegroup |
| 17-01-2022 | C4 | 10812 | 6 | 2 | Part of Tier1 customegroup |
| 24-01-2022 | C4 | 10812 | 6 | 2 | Part of Tier1 customegroup |
| 31-01-2022 | C4 | 10812 | 6 | 2 | Part of Tier1 customegroup |
| 03-01-2022 | C3 | 11144 | 5 | 1 | Part of Tier1 customegroup |
| 10-01-2022 | C3 | 11144 | 5 | 1 | Part of Tier1 customegroup |
| 17-01-2022 | C3 | 11144 | 5 | 1 | Part of Tier1 customegroup |
| 24-01-2022 | C3 | 11144 | 5 | 1 | Part of Tier1 customegroup |
| 31-01-2022 | C3 | 11144 | 5 | 1 | Part of Tier1 customegroup |
| 03-01-2022 | C7 | 11541 | 4 | 4 | Part of Tier2 customegroup |
| 10-01-2022 | C7 | 11541 | 4 | 4 | Part of Tier2 customegroup |
| 17-01-2022 | C7 | 11541 | 4 | 4 | Part of Tier2 customegroup |
| 24-01-2022 | C7 | 11541 | 4 | 4 | Part of Tier2 customegroup |
| 31-01-2022 | C7 | 11541 | 4 | 4 | Part of Tier2 customegroup |
| 03-01-2022 | C10 | 11609 | 3 | 3 | Part of Tier2 customegroup |
| 10-01-2022 | C10 | 11609 | 3 | 3 | Part of Tier2 customegroup |
| 17-01-2022 | C10 | 11609 | 3 | 3 | Part of Tier2 customegroup |
| 24-01-2022 | C10 | 11609 | 3 | 3 | Part of Tier2 customegroup |
| 31-01-2022 | C10 | 11609 | 3 | 3 | Part of Tier2 customegroup |
| 03-01-2022 | C6 | 11975 | 2 | 2 | Part of Tier2 customegroup |
| 10-01-2022 | C6 | 11975 | 2 | 2 | Part of Tier2 customegroup |
| 17-01-2022 | C6 | 11975 | 2 | 2 | Part of Tier2 customegroup |
| 24-01-2022 | C6 | 11975 | 2 | 2 | Part of Tier2 customegroup |
| 31-01-2022 | C6 | 11975 | 2 | 2 | Part of Tier2 customegroup |
| 03-01-2022 | C8 | 12756 | 1 | 1 | Part of Tier2 customegroup |
| 10-01-2022 | C8 | 12756 | 1 | 1 | Part of Tier2 customegroup |
| 17-01-2022 | C8 | 12756 | 1 | 1 | Part of Tier2 customegroup |
| 24-01-2022 | C8 | 12756 | 1 | 1 | Part of Tier2 customegroup |
| 31-01-2022 | C8 | 12756 | 1 | 1 | Part of Tier2 customegroup |