Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
BlackBull256
Regular Visitor

RankX with others does not show the correct value.

Hey all, 

 

I have a dataset which has data from multiple companies, departments with the corresponding revenue. I have a measure which ranks companies based on revenue within each department. So it not a total ranking, but a ranking on department level. 

Because I want to create a Top N filter with an others category, I have created a seperate table with all the distict Company names, and the value "Others". In my ranking measure (see code below) I tell the measure to allocate the value -1 when the Company name equals "Others", else allocate the Ranking. However, as you can see in the table, the "Others" values are still included in the ranking, whilst I actually want to see the -1 value. 

Does anyone know what I am doing wrong? Your help would be greatly appreciated. You can access the file her: https://www.dropbox.com/s/yhcfux2lzrnmm4f/RankingTestFile.pbix?dl=0

 

BlackBull256_1-1623403875205.png

 

Ranking = 
VAR Ranking = 
    RANKX(ALLSELECTED(CompanyNames[Company]),
        CALCULATE(
            SUM(Sheet1[Revenue]),
            NOT ISBLANK(Sheet1[Company]),
            ALLSELECTED(Sheet1[Company])
        ))

VAR isOthersSelected = SELECTEDVALUE(CompanyNames[Company])="Others"
VAR Result = if(isOthersSelected,-1,Ranking)
RETURN Result

 

 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @BlackBull256 ,

 

Please follow these steps:

1. Create a Company table:

Company = UNION( VALUES(Sheet1[Company]) ,{"Others"})

2. Add a measure to calculate the sum of Revenue:

Sum Revenue = CALCULATE(SUM('Sheet1'[Revenue]),FILTER('Sheet1','Sheet1'[Company]=MAX('Company'[Company])))

3. Add the rank measure:

Rank = IF(MAX('Company'[Company])="Others",-1, RANKX(ALLSELECTED(Company),[Sum Revenue],,DESC,Dense))

The final output is shown below:

rank by company.gif

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @BlackBull256 ,

 

Please follow these steps:

1. Create a Company table:

Company = UNION( VALUES(Sheet1[Company]) ,{"Others"})

2. Add a measure to calculate the sum of Revenue:

Sum Revenue = CALCULATE(SUM('Sheet1'[Revenue]),FILTER('Sheet1','Sheet1'[Company]=MAX('Company'[Company])))

3. Add the rank measure:

Rank = IF(MAX('Company'[Company])="Others",-1, RANKX(ALLSELECTED(Company),[Sum Revenue],,DESC,Dense))

The final output is shown below:

rank by company.gif

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@Anonymous , thank you very much, this works perfectly!

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors