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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
joeywong
Helper I
Helper I

TopN and "Other" filtered by month

Hi all,

 

I need to show the top five and the balance group to others in my report. I have used the following measure:

 

joeywong_0-1671793292837.png

It worked perfectly fine until I filtered it by month. When I filtered it by month, the row for "others" disappeared, and the grand total for the month was also incorrect. Can anyone help?

 

Thanks!

1 ACCEPTED SOLUTION
v-tangjie-msft
Community Support
Community Support

Hi @joeywong ,

 

According to your description, here are my steps you can follow as a solution.

(1) We can create measures. 

 

Measure =

var _top5 = TOPN(5,VALUES('Table'[Customer No]), CALCULATE(SUM('Table'[Amount])))

var _t2 = SELECTCOLUMNS(_top5,"No" , [Customer No])

var _cur_no= MAX('Unrelated ID'[Customer No])

var _others = EXCEPT(VALUES('Table'[Customer No]),_t2)

return

IF(_cur_no="other",CALCULATE(SUM('Table'[Amount]),FILTER('Table','Table'[Customer No] in _others)),IF(MAX('Unrelated ID'[Customer No]) in _t2 , CALCULATE(SUM('Table'[Amount]), FILTER('Table','Table'[Customer No]=_cur_no))  ,BLANK()))
Measure 2 =

var _total=

SUMX( CROSSJOIN(VALUES('Table'[MM YY]),VALUES('Unrelated ID'[Customer No])),[Measure])

return

_total

 

(2) Then the result is as follows.

vtangjiemsft_0-1672042425923.png

 

Best Regards,

Neeko Tang

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

7 REPLIES 7
v-tangjie-msft
Community Support
Community Support

Hi @joeywong ,

 

According to your description, here are my steps you can follow as a solution.

(1) We can create measures. 

 

Measure =

var _top5 = TOPN(5,VALUES('Table'[Customer No]), CALCULATE(SUM('Table'[Amount])))

var _t2 = SELECTCOLUMNS(_top5,"No" , [Customer No])

var _cur_no= MAX('Unrelated ID'[Customer No])

var _others = EXCEPT(VALUES('Table'[Customer No]),_t2)

return

IF(_cur_no="other",CALCULATE(SUM('Table'[Amount]),FILTER('Table','Table'[Customer No] in _others)),IF(MAX('Unrelated ID'[Customer No]) in _t2 , CALCULATE(SUM('Table'[Amount]), FILTER('Table','Table'[Customer No]=_cur_no))  ,BLANK()))
Measure 2 =

var _total=

SUMX( CROSSJOIN(VALUES('Table'[MM YY]),VALUES('Unrelated ID'[Customer No])),[Measure])

return

_total

 

(2) Then the result is as follows.

vtangjiemsft_0-1672042425923.png

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

ppm1
Solution Sage
Solution Sage

FYI on another approach to get TopN/Others functionality with the Deneb visual.

TopN and Others with Deneb in Power BI - YouTube

 

Pat

Microsoft Employee
joeywong
Helper I
Helper I

Hi AIB,

 

Thank you for your help in advance.

 

I am quite new to power bi. I am not quite sure this is the correct way to share the PBIX file. If you can't open the file, please let me know.  

 

PBIX 

Dataset 


I have tried writing these two measures (Top NR and Top NR2). Obviously, these two measures don't work.

 

Really appreciate your help. Thanks!

 

Joey

 

 

 

@joeywong 

I do not see the measure working without the filters in the pbix you shared. Not sure I understand what you need. Can you show an example with the result based on sample data?

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

@AlB 

Below is an example of the result based on sample data.

joeywong_1-1671835720854.png

Thank you once again in advance.

 

 

 

 

 

johnt75
Super User
Super User

The SQL BI guys did a video on top n and others filtered by date.

Hi @johnt75 

Can you share a pbix?

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.