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
CHCHJOSIE
Frequent Visitor

Ranking created measures

smartsheet.png

I have a smartsheet with the reasons why people have left the company, more than 1 reason can be chosen from the list of 9 possible choices. I am trying to display the top 5 reasons on my dashboard.

 

I have created a measure for each of the 9 reasons to be able to count each time the individual reason is used - 

 
Involuntary =
CALCULATE(
    COUNTA('Offboarding actions'[Reason for leaving]),
    CONTAINSSTRING('Offboarding actions'[Reason for leaving], "Involuntary")
)
 
Problem is now how to show the top 5, I've been trying to use RANKX but haven't got it to work.
 
As a completely different way I tried seperating the 'Reasons for Leaving' column by delimiter to create a seperate column but got stuck on how to group the 2 columns.
 
Still very much a beginner user! 
Thanks in advance.
1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @CHCHJOSIE 

 

You don't have to create a measure for each reason separately. You can add a table "Reason table" which has all distinct possible reasons to the model. Then there are three methods coming to my mind. 

 

Method one:

Use Power Query to split the "Reason for leaving" column. When splitting, expand Advanced options and select split into Rows rather than the default Columns. All reasons will be splitted into the same column with only one reason on one row. Then it will be easy to be counted with DAX.

 

You can apply the change to power bi desktop, create a relationship between this table and the "Reason table" created earlier based on Reason column. This is a one-to-many relationship from "Reason table" to the original data table. Then create below measure. Add the reason column to a visual and add a TOP N filter on it based on the measure. 

Measure 1 = COUNT(Demo1[Reason for leaving]). 
vjingzhang_0-1685438255208.png

 

Method 2:

Use Power Query's Group by feature to count number of reasons after splitting the column into rows. Then apply a TOP N filter on the count column. 

 

Method 3:

If you don't want to split the reason column, you can use the following measure:

Measure 3 = COUNTROWS(FILTER(Demo3,CONTAINSSTRING(Demo3[Reason for leaving],SELECTEDVALUE('Reason Table'[Reason]))))
 
I created samples of above three methods in a sample file. You can download the attachment at bottom to see details.
 
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

2 REPLIES 2
CHCHJOSIE
Frequent Visitor

Hi @v-jingzhang 

Thanks so much for the different options and great explanations.

Option 3 seemed the easiest and being inherently lazy that was the one I chose and it worked perfectly! 

😁

v-jingzhang
Community Support
Community Support

Hi @CHCHJOSIE 

 

You don't have to create a measure for each reason separately. You can add a table "Reason table" which has all distinct possible reasons to the model. Then there are three methods coming to my mind. 

 

Method one:

Use Power Query to split the "Reason for leaving" column. When splitting, expand Advanced options and select split into Rows rather than the default Columns. All reasons will be splitted into the same column with only one reason on one row. Then it will be easy to be counted with DAX.

 

You can apply the change to power bi desktop, create a relationship between this table and the "Reason table" created earlier based on Reason column. This is a one-to-many relationship from "Reason table" to the original data table. Then create below measure. Add the reason column to a visual and add a TOP N filter on it based on the measure. 

Measure 1 = COUNT(Demo1[Reason for leaving]). 
vjingzhang_0-1685438255208.png

 

Method 2:

Use Power Query's Group by feature to count number of reasons after splitting the column into rows. Then apply a TOP N filter on the count column. 

 

Method 3:

If you don't want to split the reason column, you can use the following measure:

Measure 3 = COUNTROWS(FILTER(Demo3,CONTAINSSTRING(Demo3[Reason for leaving],SELECTEDVALUE('Reason Table'[Reason]))))
 
I created samples of above three methods in a sample file. You can download the attachment at bottom to see details.
 
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

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.

Top Solution Authors