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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
RingoSun
Helper II
Helper II

Help me understand this TopN with Others

Top N Qty = 
VAR TopNSelected = SELECTEDVALUE('TopN'[TopN])
VAR TopQtyTable = 
    TOPN(
        TopNSelected,
        ALLSELECTED('PseudoBrand Table'),
        [FloorShareTotal]
    )       
VAR TopQty =
    CALCULATE(
        [FloorShareTotal],
        KEEPFILTERS( TopQtyTable)    
    )
VAR OthersQty = 
    CALCULATE(
        [FloorShareTotal],
        ALLSELECTED('PseudoBrand Table')
    ) -
    CALCULATE(
        [FloorShareTotal],
        TopQtyTable
    )
VAR CurrentBrand = SELECTEDVALUE('PseudoBrand Table'[Brand])
RETURN
    IF(
        CurrentBrand <> "Others",
        TopQty,
        OthersQty
    )

RingoSun_1-1660677879010.png

So if I take the Top N Qty measure and use it as my Y-axis in a bar chart, and the Brand from PseudoBrand Table as my X-axis. I can use the TopN slicer to let's say filter to Top 3 then the bar chart will only show me the Top 3 brands and the rest of the brands will be under Others. 

 

Please help me understand how all of these works, especially the variables.

 

Thank you!

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @RingoSun 

Thanks for reaching out to us.

Please see this article, TOPN function (DAX) - DAX | Microsoft Docs

vxiaotang_1-1660890858897.png

 

 

Best Regards,

Community Support Team _Tang

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

View solution in original post

2 REPLIES 2
v-xiaotang
Community Support
Community Support

Hi @RingoSun 

Thanks for reaching out to us.

Please see this article, TOPN function (DAX) - DAX | Microsoft Docs

vxiaotang_1-1660890858897.png

 

 

Best Regards,

Community Support Team _Tang

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

Fowmy
Super User
Super User

@RingoSun 

I would suggest the following video from sqlbi.com : https://youtu.be/nVvlEHKr_0o

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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