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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

TopN + Others

Hi Dear Community,

 

I have created this Table and measure in order to get Top 5 cases.

 

Top casestable:

 

Top Cases2 = filter(UNION(DISTINCT('Cases'[L1_SubjectDesc]), DATATABLE("L1_SubjectDesc",STRING, {{"Others"}})), not ISBLANK('Cases'[L1_SubjectDesc]))
 
I also created 1:* relationship between this new table and Cases table.
 
And measure to sum top 5 cases count and the rest of cases count as "Others" :
 
Top 5 cases2 =
var TopCaseTable = TOPN(5, ALLSELECTED('Top Cases2'), [Case Count])

var TopCaseCount = CALCULATE([Case Count], KEEPFILTERS(TopCaseTable))

var OtherCases = CALCULATE([Case Count], ALLSELECTED('Top Cases2')) - CALCULATE([Case Count], TopCaseTable)

var CurrentCase = SELECTEDVALUE('Top Cases2'[L1_SubjectDesc])

Return
IF(CurrentCase <> "Others",
TopCaseCount,
OtherCases)
 
The problem:
 
The measure seems to work on table (without adding date field though) but not on matrix. The 2 fields are from Top Cases2 table:
GG_PBI_0-1655920386791.png

 And itdoesn't work on a stacked bar chrat. First the legend shows all the subjects instead of top 5, then it seems to not show the top 5 of the cases.

GG_PBI_1-1655920507255.png

 

 with the legend, which is from the Top Cases2 table.
 
Will appreciate your help to figure this issue out.
 
Cheers!
1 REPLY 1
amitchandak
Super User
Super User

@Anonymous , do you need TOPN with others

 

Refer video from curbal -https://www.youtube.com/watch?v=UAnylK9bm1I

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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