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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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/

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.