Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I am trying to build a table, with ranking based on each product's sales, ignoring the sub-category.
Ranking | Product | Product Sub-Category | Sales |
1 | Health | 1 | 1000 |
1 | Health | 2 | 2000 |
1 | Health | 3 | 3000 |
2 | Living | 2 | 500 |
2 | Living | 4 | 200 |
2 | Living | 5 | 600 |
3 | Dining | 10 | 100 |
The DAX expression that I am using :
RANKX(
ALL(Product),
CALCULATE(Sales, ALL(Product Sub-Category)),
,DESC,
Dense)
However, there's a filter applying to this table, which is Area Code, when I choose more than one area code, for example, two area code, the table will return two rank 1 ( 1 from area A and 1 from area B).
How can I solve this problem ? Many thanks
Hi @Anonymous,
Attached PBIX file for reference.
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data
Hi @Anonymous
you can try
Ranking =
RANKX (
CALCULATETABLE ( Product, ALLEXCEPT ( Product, Product[Area] ) ),
CALCULATE ( [Sales], ALL ( Product[Sub-Category] ) ),
,
DESC,
DENSE
)
Hi @tamerj1 ,
Thank you for your suggestion. The ranking are according to their sales now, but one of the issue is that the ranking are not in sequence 1 by 1
Now the table is like this :
Ranking | Product | Product Sub-Category | Sales |
1 | Health | 5 | 1000 |
1 | Health | 10 | 2000 |
4 | Living | 2 | 3000 |
4 | Living | 3 | 500 |
4 | Living | 4 | 200 |
4 | Living | 5 | 600 |
7 | Dining | 1 | 100 |
7 | Dining | 3 | 100 |
7 | Dining | 5 | 200 |
7 | Dining | 10 | 300 |
11 | Clothes | 3 | 50 |
11 | Clothes | 5 | 100 |
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
37 | |
25 | |
19 | |
14 | |
8 |
User | Count |
---|---|
69 | |
48 | |
44 | |
19 | |
15 |