How can I use RANKX in DAX to rank customers within each region while keeping ties properly handled

0 votes

How can I use RANKX() in DAX to rank customers within each region while keeping ties properly handled?
I need a Power BI measure that ranks customers within each region using RANKX, ensuring that ties are properly handled without skipping ranks. What is the best way to structure the DAX formula to achieve correct rankings while considering filter contexts?

2 days ago in Power BI by Evanjalin
• 19,000 points
13 views

1 answer to this question.

0 votes

The RANKX() function allows you to rank customers in each region while taking care of tied ranks. Therefore, make sure ranking is calculated over a context filtered by area, not skipping ranks due to tie situations.

DAX Measure to Rank Customers in Each Region

Customer Rank = 
RANKX(
    CALCULATETABLE( 
        VALUES( 'Customers'[CustomerName] ), 
        ALLSELECTED( 'Customers' ) 
    ),
    CALCULATE( SUM( 'Sales'[TotalSales] ) ),
    , 
    DESC, 
    DENSE
)

Explanation:

CALCULATETABLE(VALUES('Customers'[CustomerName]), ALLSELECTED('Customers'))

Creates a virtual table containing unique customers within the selected region so that ranking is done per region.

CALCULATE(SUM('Sales'[TotalSales]))

Defines the ranking criteria (total sales per customer).

RANKX(..., ..., DESC, DENSE)

DESC → Ranks in descending order (highest sales first).

DENSE → Tied values receive the same rank, while the next rank is given without skipping.

Handling Filter Context

The ranking will respect all active filters applied in the ALLSELECTED function, for instance, a particular region selected in a slicer.  

If you want to ignore all slicers that affect regions in the rankings, replace ALLSELECTED('Customers') with ALL('Customers').

This will ensure that customers are ranked properly within each region without skipping the sequence for any ties.

answered 2 days ago by anonymous
• 19,000 points

Related Questions In Power BI

0 votes
1 answer

How can I unpivot multiple columns dynamically while keeping other columns unchanged in Power Query?

To dynamically unpivot multiple columns in Power ...READ MORE

answered 20 hours ago in Power BI by anonymous
• 19,000 points
16 views
0 votes
1 answer

How to use Dynamic DAX Number Format in power BI?

You can give them the same display ...READ MORE

answered Dec 8, 2020 in Power BI by Gitika
• 65,770 points
2,525 views
0 votes
1 answer

How to use No QUARTER() in DAX in power BI?

One should use =ROUNDUP(MONTH([Date])/3, 0) to get quarte ...READ MORE

answered Dec 8, 2020 in Power BI by Gitika
• 65,770 points
890 views
0 votes
0 answers

How can I debug complex DAX formulas effectively in Power BI?

Oct 11, 2024 in Power BI by anonymous
• 19,000 points
270 views
+2 votes
0 answers

Assume referential integrity

1) What is Assume referential integrity? what ...READ MORE

Aug 19, 2019 in Power BI by vnk
1,920 views
+2 votes
1 answer

If Condition

DAX - I assume [Claim_line].[Allowed_Amount_B6] is one ...READ MORE

answered Aug 20, 2019 in Power BI by anonymous
• 33,030 points
1,715 views
+2 votes
1 answer

How to export data to CSV from power bi embedded url ?

Hi Arathi, You can open Visuals from embedded ...READ MORE

answered Aug 23, 2019 in Power BI by anonymous
• 33,030 points
6,775 views
+1 vote
1 answer

Power Bi to Machine Learning Model

Hello @vnk! Power BI only supports Azure Machine ...READ MORE

answered Dec 3, 2019 in Power BI by Priyanka
1,298 views
0 votes
1 answer

I need to calculate a running total but reset it at the start of each new quarter—how can I achieve this in DAX?

To calculate a running total that resets ...READ MORE

answered 4 days ago in Power BI by anonymous
• 19,000 points
42 views
0 votes
1 answer

I want to calculate the distinct count of active customers but only for the last three completed months—how can I do this in DAX?

To calculate the distinct count of active ...READ MORE

answered 2 days ago in Power BI by anonymous
• 19,000 points
24 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP