Forum Discussion
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.
| Code | Category | CIR | Value |
| A1 | New | 10 | 93 |
| B2 | On-Air | 50 | 95 |
| C4 | New | 5 | 83 |
| D4 | Active | 800 | 75 |
| E3 | Active | 2000 | 47 |
| F3 | Active | 8 | 32 |
| G2 | New | 10 | 14 |
| H1 | On-Air | 250 | 50 |
| K1 | On-Air | 600 | 23 |
| L2 | New | 100 | 100 |
| M3 | On-Air | 500 | 60 |
| A3 | New | 5 | 47 |
| B3 | Active | 80 | 54 |
| C10 | Active | 20 | 24 |
| D5 | Active | 8 | 58 |
| G1 | New | 120 | 75 |
| H3 | On-Air | 20 | 95 |
| K2 | On-Air | 60 | 48 |
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
- AnonymousNot applicable
bumping it to see if anyone can help, please
- viviank
Resolver I
I always have to watch a video or google to remind myself how to do this.
I know you want to use RANKX to get the Top X (in this case the Top 2).
Try watching this: https://www.youtube.com/watch?v=TSOL213OqwY
- v-yalanwu-msft
Community 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.- AnonymousNot 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
Community 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.