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
thomsontam
Frequent Visitor

Top N and other by grand total with monthly matrix table

Hi All,

 

I followed the following links and created Top 5 + Others for my report table.

 

https://www.sqlbi.com/articles/showing-the-top-5-products-and-others-row/

https://community.powerbi.com/t5/Desktop/Top-10-Other/m-p/51282

https://community.powerbi.com/t5/Desktop/Dynamic-Top-N-and-Others-category/m-p/614566#M292949

 

It works great on grand total level, however, if I put the formula into a monthly matrix table then it is unable to provide correct information.

 

e.g.

In grand total table, I got the following:

CompanyTotal
AAA50
BBB45
CCC40
Other65
Total200

 

However, when I transform it into a monthly matrix table, it shows as below

CompanyP1P2P3Total
AAA20152050
BBB15141645
CCC14 1440
DDD 13  
Other21182065
Total706070200

instead of

CompanyP1P2P3Total
AAA20152050
BBB15141645
CCC14121440
Other21192065
Total706070200

 

Thanks for your help!

2 REPLIES 2
amitchandak
Super User
Super User

@thomsontam , Can share your topN measure?

I think because of context topN will work for each period and give Top 5 for those. You might have force allexcept (Table, Table[Company])

Rank =IF (AND (NOT ( ISBLANK ( [Top & Other] ) ),ISFILTERED ( SalesData[Company] )),RANKX ( ALL(SalesData[Company] ), [Sales Total] ))

 

Sales Top = CALCULATE ([Sales Total],KEEPFILTERS (TOPN ( [TopN Selection], ALL ( SalesData[Company] ), [Sales Total] )))

 

Sales Other = CALCULATE ([Sales Total], KEEPFILTERS (EXCEPT (ALL ( SalesData[Company]),TOPN ( [TopN Selection], ALL ( SalesData[Company] ), [Sales Total] ))))

 

Sales Other Total Only =
IF ( NOT ( ISFILTERED ( SalesData[Company] ) ), [Sales Other] )

Sales Top & Other =
IF (
HASONEVALUE ( 'Top & Other'[Top & Other] ),
SWITCH (
VALUES ( 'Top & Other'[Top & Other] ),
"Top", [Sales Top],
"Other", [Sales Other Total Only]
),
[Sales Total]
)

Sales Total =
SUM ( SalesData[Sales Amount] )

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.