Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
I was trying to make a rank measure to take rank Customer based on their Sales. However, I need to avoid certain customers such as XXX and blank customers in the ranking or add them to a default ranking. Unfortunately, it is not working for me. Below is an example and the expected output as Rank.
| Customer | Sales | Rank |
| E | 5000 | 1 |
| C | 2000 | 2 |
| XXX | 600 | |
| B | 500 | 3 |
| 200 | ||
| Z | 150 | 4 |
| A | 100 | 5 |
| T | 50 | 6 |
| R | 10 | 7 |
The dax calculation I am using is
Rank =
IF (
SELECTEDVALUE ( Query1[Customer] ) IN { "XXX", "" }, -100, //applying default rank of -100
RANKX (
FILTER ( ALL ( Query1 ), NOT ( Query1[Customer] IN { "XXX", "" } ) ),
[Sales],
,
DESC
)
)
Please help
Solved! Go to Solution.
I managed to frame the dax with the tips from @DataInsights . Thanks. Below is the final working solution
Ranking Customers Asc =
IF (
NOT MAX ( Query1[Customers] ) IN { "XXX", BLANK (), "" },
//Filtering unwanted customers like XXX and blanks
CALCULATE (
RANKX ( ALL ( Query1[Customers] ), [Sales],, ASC, DENSE )
),
//applying rank
100 //giving default rank of 100 to unwanted customer
)
I managed to frame the dax with the tips from @DataInsights . Thanks. Below is the final working solution
Ranking Customers Asc =
IF (
NOT MAX ( Query1[Customers] ) IN { "XXX", BLANK (), "" },
//Filtering unwanted customers like XXX and blanks
CALCULATE (
RANKX ( ALL ( Query1[Customers] ), [Sales],, ASC, DENSE )
),
//applying rank
100 //giving default rank of 100 to unwanted customer
)
Try this measure:
Rank =
IF (
NOT MAX ( Query1[Customer] ) IN { "XXX", "" },
RANKX (
FILTER ( ALL ( Query1 ), NOT Query1[Customer] IN { "XXX", "" } ),
[Sales],
,
DESC
)
)
Proud to be a Super User!
Thank you for the help. Unfortunately, it is not working for me. The ranking is random. Please see below screenshot. I am checking on the worst profit (or loss) ranking.
Please provide a sanitized pbix using one of the file services (e.g., OneDrive) and I'll look at it.
Proud to be a Super User!
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 56 | |
| 52 | |
| 45 | |
| 17 | |
| 16 |
| User | Count |
|---|---|
| 108 | |
| 108 | |
| 39 | |
| 33 | |
| 25 |