Forum Discussion

RingoSun's avatar
RingoSun
Icon for Helper II rankHelper II
4 years ago
Solved

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
    )

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!

2 Replies