Showing results for 
Search instead for 
Did you mean: 
Helper I
Helper I

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])

IF(CurrentCase <> "Others",
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:

 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.



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

@GG_PBI , do you need TOPN with others


Refer video from curbal -

Power BI Features || Datamarts: || Field Parameters :
Time Intelligence Decoded :
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Dashboard of My Blogs !! Connect on Linkedin !! Subscribe to my youtube Channel !!
Want To Learn Power BI | Beginners !! Advance Concepts !! Power BI For Tableau User !!

Helpful resources

August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors