Forum Discussion

shalabh's avatar
shalabh
Icon for Helper I rankHelper I
2 years ago
Solved

top N with % on total

Hi,   I want to show the top 3 verticals by sales as a % of grand total (not top 5 total).    Example   Industry Sales show in table or stacked column A 40 40% B 30 30% C 20 ...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi shalabh ,

     

    Please follow these steps:

    1.        add new measure "SORT"

    SORT = 
    RANKX (
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Sales] ),
        CALCULATE ( MAX ( 'Table'[Sales] ) ),
        ,
        DESC
    )
    
    1.        add new measure "RESULT"

     

    RESULT = 
    VAR _1 =
        SUMX ( ALL ( 'Table' ), 'Table'[Sales] )
    VAR _2 =
        MAX ( 'Table'[Sales] ) / _1
    RETURN
        IF ( 'Table'[SORT] <= 3, _2, BLANK () )
    

    3.final output

     

    How to Get Your Question Answered Quickly - Microsoft Fabric Community

    If it does not help, please provide more details with your desired out put and pbix file without privacy information.

     

    Best Regards,

    Yifan Wang

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