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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

Grouping categories in single column for slicer

Hello,

 

I have a list of accounts which have been categorised in a single column to indicate whether they are in the 'Top 10', 'Top 50', 'Top 100' firms etc.

 

At the moment, when I use a slicer and click 'T10' it will show the top 10 accounts, however, when I select 'T50' it will only show those categorised as 'T50' and not the 'T10' accounts as well.

 

How could I transform the data so that:

 

- When click 'T50' on slicer it would show: account categorised as T50 and T10

- When click 'T100' on slicer it would show: accounts categorised as T100, T50 and T10 etc.

 

Hope this makes sense. Would appreciate any guidance.

 

Many thanks.

9 REPLIES 9
nandukrishnavs
Community Champion
Community Champion

@Anonymous 

 

 

Rank Category
Top 10
Top 20
Top 50

 

CompanySales
Company1100
Company2120
Company3140
Company4160
Company5180
Company6200
Company7220
Company8240
Company9260
Company10280
Company11300
Company12320
Company13340
Company14360
Company15380
Company16400
Company17420
Company18440
Company19460
Company20480
Company21500
Company22520
Company23540
Company24560
Company25580
Company26600
Company27620
Company28640
Company29660
Company30680
Company31700
Company32720
Company33740
Company34760
Company35780
Company36800
Company37820
Company38840
Company39860
Company40880
Company41900
Company42920
Company43940
Company44960
Company45980
Company461000
Company471020
Company481040
Company491060
Company501080
Company511100
Company521120
Company531140
Company541160
Company551180
Company561200
Company571220
Company581240
Company591260
Company601280
Company611300
Company621320
Company631340
Company641360
Company651380
Company661400
Company671420
Company681440
Company691460
Company701480
Company711500
Company721520
Company731540
Company741560
Company751580
Company761600
Company771620
Company781640
Company791660
Company801680
Company811700
Company821720
Company831740
Company841760
Company851780
Company861800
Company871820
Company881840

 

Calculated Column 

 

Rank = RANKX('Table','Table'[Sales],,DESC,Dense)

 

Measure

 

FilterMeasure = 
var _slectedCategory= CALCULATE(SELECTEDVALUE(RankSlicer[Rank Category]))
var _selectedRank= CALCULATE(SELECTEDVALUE('Table'[Rank]))
var _result= SWITCH(_slectedCategory,"Top 10",IF(_selectedRank<=10,"Show"),"Top 20",IF(_selectedRank<=20,"Show"),"Top 50",IF(_selectedRank<=50,"Show"))
return _result

 

Capture.JPG


Now you can apply a visual level filter to show only required values.


Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂

 


Regards,
Nandu Krishna

Anonymous
Not applicable

Thanks very much for your response.

 

I'm quite new to PBI so apologies for my basic question but if I already have a column in the data which ranks accounts from 1-100 I wouldn't need to do the first step, right? If the name of this column is 'SalesRank', where in the formula would I refer to this column?

 

Thanks again.

@Anonymous  If you already have the Rank column, you don't need to calculate it again. 

I would recommend you to implement the above solution, so you will understand the steps. Then you can tweak the logic based on your requirement.



Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂

 


Regards,
Nandu Krishna

In that case, try this: 

First create a new TABLE to get:

 

CategoryRank
T1010
T2020
T5050
 
If your Category just has T before the number, (ie 1 character), then you can use this DAX to create the table (though it is preferred to create it in Query Editor):
 
CatInd = ADDCOLUMNS(VALUES(Accounts[Category]),"Rank", RIGHT(Accounts[Category],LEN(Accounts[Category])-1))

 

Then your MEASURE formula will be: 

Show = IF(SELECTEDVALUE(CatIndex[Rank], 1000)>=SELECTEDVALUE(Accounts[SalesRank],0),"Yes","No")
 

The 1000 number ensures that if nothing is selected in the slicer, all accounts will display, so make that number higher if needed. 

 

Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved. 

 

If you found this post helpful, please give Kudos.

I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 

https://sites.google.com/site/allisonkennedycv


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

Apologies again but I have created measure as instructed but not sure how to apply this measure to the slicer / visual. Can you please explain? 

 

Thanks again

@Anonymous 

Click slicer visul and drag Rank Category column to its value field. Click table visul and add required columns to its value field. Now select newly created table visual and goto its filter section ( right side ). Drag "FilterMeasure" into visual level filter and set show value is show.

 

https://www.sqlbi.com/articles/applying-a-measure-filter-in-power-bi/ 



Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂


Regards,
Nandu Krishna

AllisonKennedy
Super User
Super User

You will need to have the categories indexed in a separate table (not with the list of accounts table) and not related to the accounts table:

 

CatIndex = 

CategoryIndex
Top 101
Top 502
Top 1003

 

Use that CatIndex[Category] for your slicer.

 

Ideally you will also have the CatIndex as a COLUMN in the accounts table: 

 

CatIndex=SWITCH(Accounts[Category], "Top 10", 1, "Top 50", 2, "Top 100", 3)

 

Then create a new MEASURE to decide whether to Display the row or not: 

Display = IF(SELECTEDVALUE(CatIndex[Index],100)>=SELECTEDVALUE(Accounts[CatIndex], 0),"Yes", "No")
 
Finally, use the new measure as a Visual Level filter on the matrix and set filter to Yes only.

 

Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved. 

 

If you found this post helpful, please give Kudos.

I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 

https://sites.google.com/site/allisonkennedycv


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

nandukrishnavs
Community Champion
Community Champion

@Anonymous 

 

Refer to this example https://community.powerbi.com/t5/Desktop/Dynamic-TOP-N-list/m-p/1091863/highlight/true#M505718



Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂


Regards,
Nandu Krishna

nandukrishnavs
Community Champion
Community Champion

@Anonymous 

 

First, you have to create a Rank column. https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns

Then create another table with Rank Group category. Now you can use that Rank category in a slicer. And create a Measure to filter the Table based on selected Rank. You can use SELECTVALUE() for getting the selected category and check if the rank is less than or equal to rank value. You can use this measure as a visual level filter.



Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂

 


Regards,
Nandu Krishna

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.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors