Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Top N value based on category

Hello I need help to have filter for top N for  column "Values" for each category. if I can have button for top 2 values and once I  select a slicer filter for category  = New, it show me all the columns where values are the higest 2, that in this case, rows L2 & A1 and show in the assending order of values.

 

CodeCategoryCIRValue
A1New1093
B2On-Air5095
C4New583
D4Active80075
E3Active200047
F3Active832
G2New1014
H1On-Air25050
K1On-Air60023
L2New100100
M3On-Air50060
A3New547
B3Active8054
C10Active2024
D5Active858
G1New12075
H3On-Air2095
K2On-Air6048
  • Hi,  Anonymous ;

    You could create a flag measure.

    Flag = IF( RANKX(FILTER(ALLSELECTED('Table'),[Category]=MAX('Table'[Category])),CALCULATE(SUM('Table'[Value])),,DESC)<=2,1)

    Then apply it into filter.

    The final show:


    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    bumping it to see if anyone can help, please

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    Icon for Community Support rankCommunity Support

    Hi,  Anonymous ;

    You could create a flag measure.

    Flag = IF( RANKX(FILTER(ALLSELECTED('Table'),[Category]=MAX('Table'[Category])),CALCULATE(SUM('Table'[Value])),,DESC)<=2,1)

    Then apply it into filter.

    The final show:


    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Can we create a button that we can use to select top 2 once clicked rather than once the category selection, please?

      • v-yalanwu-msft's avatar
        v-yalanwu-msft
        Icon for Community Support rankCommunity Support

        Hi, Anonymous ;

        The button is not a filter, but the button can link to other pages. Can you share the scene display you wish to export? Is the button fixed to the top 2 or can you select the top 3, top 4...


        Best Regards,
        Community Support Team _ Yalan Wu
        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.