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

Dynamic Top 10 to use as legend

Hi, hoping someone can help with a solution to my query:

 

In a pie chart, I'd like to be able to show the top 10 categories and an "other" category to encompass the rest. I.e. the pie chart below would only show the largest 10 segments separately and then group everything else into an "other" segment.

 

Laura-_0-1600954225147.png

 

We need the top 10 to be dynamic so will change with filtering - we could have 2 completely different "top 10s" depending on the filters put on the chart by the end user.

 

Is this possible? Thank you in advance for your help!

 

1 ACCEPTED SOLUTION

Hi @Anonymous 

 

Let me know whether you'd like to get below one:

 

Measure = DISTINCTCOUNT(Transactions[TransactionID])
Measure 2 = var a = RANKX(ALL(Demographics[AgeBand]),[Measure],,DESC)
return IF(a<=10,a,"Other")

 

006.PNG

If you'd like to get the calculated column, try below formula:

Column = RANKX(ALL(Demographics[AgeBand]),CALCULATE(DISTINCTCOUNT(Transactions[TransactionID]),ALLEXCEPT(Demographics,Demographics[AgeBand])),,DESC)

and set the column as "Do not summarize"

007.PNG

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

In between have look at this video, this can help :https://www.youtube.com/watch?v=UAnylK9bm1I

Anonymous
Not applicable

Hi @amitchandak , Sorry, posting again as I don't think my original reply was correct:

 

The data tables in their most basic form look like this with a 1:1 relationship on the Key column:

 

Transactions:

KeyTransactionID
1transaction001
2transaction002
3transaction003
4transaction004
5transaction005
6transaction006
7transaction007
8transaction008
9transaction009
10transaction010

 

Demographics:

KeyAgeBand
1Under 2 Yrs
240-45 Yrs
350-55 Yrs
450-55 Yrs
550-55 Yrs
625-30 Yrs
740-45 Yrs
830-35 Yrs
9Over 100 Yrs
1030-35 Yrs

 

 

The particular data above would result in the following table/piechart:

 

AgeBandCount of TransactionID
Under 2 Yrs1
25-30 Yrs1
30-35 Yrs2
40-45 Yrs2
50-55 Yrs3
Over 100 Yrs1

 

but if there were more than 10 categories then the smallest categories after the top 10 would be shown as "Other".

 

Sorry, I didn't spot your youtube link at first - I have had a look at creating a column like the video but it doesn't seem to work 100% for me - I think it is to do with filters put on the report:

 

New column I tried to create in the table AgeBands, where "AgeBands" is just a table showing a list of the possible age bands (with a relationship with the AgeBand column in Demographics table) and TransactionsCount is a measure doing COUNTA(Transactions[TransactionID]):

 

Age Band Top 10 =
var RankAgeBandbyCount = RANKX(all(AgeBands), [TransactionsCount],,desc)
return
if(RankAgeBandbyCount<=10,AgeBands[AgeBand],"Other")

Hi @Anonymous 

 

Let me know whether you'd like to get below one:

 

Measure = DISTINCTCOUNT(Transactions[TransactionID])
Measure 2 = var a = RANKX(ALL(Demographics[AgeBand]),[Measure],,DESC)
return IF(a<=10,a,"Other")

 

006.PNG

If you'd like to get the calculated column, try below formula:

Column = RANKX(ALL(Demographics[AgeBand]),CALCULATE(DISTINCTCOUNT(Transactions[TransactionID]),ALLEXCEPT(Demographics,Demographics[AgeBand])),,DESC)

and set the column as "Do not summarize"

007.PNG

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

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.