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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

TOPN for two columns

I have three columns in subscriber dataset. - Customer ID, Monthly Charges and total Charges.

I grouped Monthly charges column as below

 

0 to 20
21 to 40
41 to 60
61 to 80
81 to 100
Greater than 100

 

I need to display top 5 customer IDs according to "total charges" for each group of "Monthly charges". How do I do that?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

You can follow the steps below to get the Top5 values.

 

1. Create a measure to sum Total Charges

SumTotal = SUM(Data[TotalCharges])

2018-10-19_11-26-57.png

2. Create a measure to get the Rank number

Rank = RANKX(ALL(Data[Customers]),[SumTotal],,DESC)

 3. Create a Matrix using Monthly Charges, Customer, SumTotal and Rank than use filter feature to only show Top5

2018-10-19_11-29-27.png

 

 

 

View solution in original post

4 REPLIES 4
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous

 

You can create a RANK column to RANK each ID within these GROUPs (using RANKX dax function)

 

Then you can use a VISUAL filter with RANK <=5 to get TOP5 IDs for each Group


Regards
Zubair

Please try my custom visuals
Anonymous
Not applicable

 

Hi Zubair,

I tried this but ranking is not working for me.

 

 

Rank = RANKX(Data, Data[TotalCharges],1,ASC,Dense)

ranking.PNG

 

pbix file : https://1drv.ms/u/s!AhVscPhmToJ0k7gby4TGxHoEdq9z8Q

 

 

 

Anonymous
Not applicable

You can follow the steps below to get the Top5 values.

 

1. Create a measure to sum Total Charges

SumTotal = SUM(Data[TotalCharges])

2018-10-19_11-26-57.png

2. Create a measure to get the Rank number

Rank = RANKX(ALL(Data[Customers]),[SumTotal],,DESC)

 3. Create a Matrix using Monthly Charges, Customer, SumTotal and Rank than use filter feature to only show Top5

2018-10-19_11-29-27.png

 

 

 

Anonymous
Not applicable

Hi @Anonymous,

Incredibale! Thanks a lot Smiley Happy

But i have no idea how it works. Smiley Tongue Is it fairly difficult level task?

 

Are there any tutorials available to practice DAX functions?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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