The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
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 |
User | Count |
---|---|
14 | |
11 | |
6 | |
6 | |
5 |
User | Count |
---|---|
28 | |
18 | |
12 | |
7 | |
5 |