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
primolee
Helper V
Helper V

Dynamic TopN with 2 Layers knowing what's in "Others"

Hello everyone,

 

https://www.youtube.com/watch?v=yGFcCbXn_g0 

 

I use this tutorial from Goodly as reference to build my TopN model, however, I want to be able to find out what products are in "Others" so I can use matrix grid or bar chart with 2 layers, having "Others" on the first layer and then still be able to expand "Others" to find out what products are in "Others".

 

I tried many ways such as summarizing each product's sales in the table, but I then have no "Others" as product.  Could anyone please help me with this?  Thank you.

 

Best regards,

David

6 REPLIES 6
CNENFRNL
Community Champion
Community Champion

Obviously, the essence of the viz under the hood is just a flat table; it doesn't make any sense to drill down.

CNENFRNL_0-1654680223471.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

After sorting top N of your choice dynamically, if anyone wants to know what are in "Others", it will be necessary to drill down.  There might be hundreds of products, and I want to know what Others and their sales are.

 

I can have another similar table with all products in the report, but it will be redundant since I have the above table already.

danextian
Super User
Super User

Hi @primolee ,

 

Based on just the info provided, I'd create another measure for Others. So that would be:

Others = 
[Measure used in TopN] - [TopN Measure]

 Then use both TopN and Others in a visual.










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hello @danextian ,

 

Sorry I did not explain clear enough. (Or maybe I don't understand what you mean...)

 

for example:

ProductSalesRank
A1001
B502
C253
D124
E65
F35
G25

 

If I want Top 4, EFG will all be categoried as "Others" like the following pic.

未命名.jpg

 

But in this chart, I won't know what are in "Others".  I want to be able to expand the next level to show "Others" detail product.

 

Is there a way to do so?  Thanks.

 

Attached is the sample pbix provided by Goodly.

https://www.youtube.com/redirect?event=comments&redir_token=QUFFLUhqbU1yaldTX1dpMTh5MFhDdTJqZEU4eXlX... 

 

Best regards,

David

Hi @primolee,

 

So I created this measure and some others in DAX that might be handy for your use case.

Top Product Sales = 
VAR TopProducts =
    CALCULATE (
        [Sales],
        'Table'[Product] IN VALUES ( Products[Product] ),
        FILTER ( 'Table', 'Table'[Rank] <= 4 )
    )
VAR OtherProducts = CALCULATE (
        [Sales],
        FILTER ( 'Table', 'Table'[Rank] > 4 )
    )
RETURN
    IF (
        SELECTEDVALUE ( Products[Product] ) = "Others",
        OtherProducts,
        TopProducts
    )

danextian_0-1654673379605.png

 

Please refer to this PBIX for the details- https://drive.google.com/file/d/1PQNhrn2wbRIRcQrqDX2augi_N-4J5sZT/view?usp=sharing 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hello @danextian ,

 

So close!  I just tried to modify your code, but still failed.  But I think we are getting very close.

 

The example in Goodly's video is having a dynamic Top N selection.  Therefore, the column "Rank" does not exist.  I can dynamically change how many top N I want.  I tried to replace "4" in your code with a rank measure and it does not work.  I think my ranking measure won't work in filter.

 

Please download the youtube link in my previous post, it is a pbix file.

https://chandeepchhabra-my.sharepoint.com/personal/chandeepchhabra_chandeepchhabra_onmicrosoft_com/_... 

 

Please use this pbix and see if you can solve it.

 

Thank you so much for your time and help!

 

Best regards,

David

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.