Reply
misterlau14
Frequent Visitor

Calculate the rank based on number of times a value occurs in a column (excluding specific values)

Hi everyone, I'd like to receive some assistance please

 

Background

I have a column of Occupation data that contains various reported responses.

 

New column created

So far, I have created a new column that counts the number of times each reported response occurs in the 'Occupation' column.

Count_Occupation =
COUNTROWS(
    FILTER('ALL Arrivals data', 'ALL Arrivals data'[Occupation] = EARLIER('ALL Arrivals data'[Occupation])))
 
This new column produces the correct output as required, so no issues here.

Ideal output

I would like to create a new column (or a new measure) that calculates the rank (based on the count of the number of times that each reported response occurs in the 'Occupation' column) - however it has to exclude the following reported responses:

  • Not Stated
  • Not Previously Employed

What I have created so far

I have currently created a new column called Rank_Count_Occupation that calculates the rank, however it does not exclude the 2 responses mentioned above.

 

Rank_Count_Occupation =
RANKX('ALL Arrivals data',('ALL Arrivals data'[Count_Occupation]),,DESC, Dense)
 
This is the current output in a table:
RankingOccupationNumber of arrivals
1Not Stated4891
2Non Working Child4522
3Not Previously Employed4114
4Occupation Unknown3526
5Home Duties1846
 
However, the output I am wanting is in this table below:

RankingOccupationNumber of arrivals
 Not Stated4891
1Non Working Child4522
 Not Previously Employed4114
2Occupation Unknown3526
3Home Duties1846

Seeking your assistance
I think I'm 80% of the way there with the new columns I have created up to this point but need to add in one last thing to the current DAX code to exclude the 'Not Stated' and 'Not Previously Employed' responses.
 
Can someone please help me with how to go about creating a new column (or a new measure) to obtain the required output (in purple text) in the second table above?

Thanks all
1 ACCEPTED SOLUTION

Hi,

This measure works

Measure 1 = RANK(DENSE,FILTER(ALL('ALL Arrivals data'[Grouping_Occupation]),'ALL Arrivals data'[Grouping_Occupation]<>"Not stated"&&'ALL Arrivals data'[Grouping_Occupation]<>"Not previously employed"),orderby([Count_Occupation_],DESC))

Hope this helps.

Ashish_Mathur_0-1729048291279.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Share the download link of the PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Power BI file - Occupation data only 

 

Hi, please see above link.

Thanks

Hi,

This measure works

Measure 1 = RANK(DENSE,FILTER(ALL('ALL Arrivals data'[Grouping_Occupation]),'ALL Arrivals data'[Grouping_Occupation]<>"Not stated"&&'ALL Arrivals data'[Grouping_Occupation]<>"Not previously employed"),orderby([Count_Occupation_],DESC))

Hope this helps.

Ashish_Mathur_0-1729048291279.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thank you so much for your help - your measure did the job nicely 🙂

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
avatar user

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

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

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)