Forum Discussion
How to add Multiple TopN to a single visual? (Either using a filter or the function)
Here is the scenario
There are Fruits and Sub fruits being collected from various farms and this needs to be visualized in a table. Below is a sample of the table.
| Fruit | Farm | Value | Sub Fruit Type |
| Fruit 1 | Farm 1 | 182 | Fruit 1 Sub 4 |
| Fruit 1 | Farm 2 | 825 | Fruit 1 Sub 3 |
| Fruit 1 | Farm 3 | 520 | Fruit 1 Sub 2 |
| Fruit 1 | Farm 4 | 634 | Fruit 1 Sub 1 |
| Fruit 2 | Farm 1 | 31 | Fruit 2 Sub 4 |
| Fruit 2 | Farm 2 | 311 | Fruit 2 Sub 3 |
| Fruit 2 | Farm 3 | 144 | Fruit 2 Sub 2 |
| Fruit 2 | Farm 4 | 47 | Fruit 2 Sub 1 |
| Fruit 3 | Farm 1 | 870 | Fruit 3 Sub 4 |
| Fruit 3 | Farm 2 | 223 | Fruit 3 Sub 3 |
| Fruit 3 | Farm 3 | 736 | Fruit 3 Sub 2 |
| Fruit 3 | Farm 4 | 598 | Fruit 3 Sub 1 |
| Fruit 4 | Farm 1 | 26 | Fruit 4 Sub 4 |
| Fruit 4 | Farm 2 | 729 | Fruit 4 Sub 3 |
| Fruit 4 | Farm 3 | 197 | Fruit 4 Sub 2 |
| Fruit 4 | Farm 4 | 384 | Fruit 4 Sub 1 |
| Fruit 5 | Farm 1 | 740 | Fruit 5 Sub 4 |
| Fruit 5 | Farm 2 | 475 | Fruit 5 Sub 3 |
| Fruit 5 | Farm 3 | 970 | Fruit 5 Sub 2 |
| Fruit 5 | Farm 4 | 790 | Fruit 5 Sub 1 |
| Fruit 6 | Farm 1 | 808 | Fruit 6 Sub 4 |
| Fruit 6 | Farm 2 | 136 | Fruit 6 Sub 3 |
| Fruit 6 | Farm 3 | 630 | Fruit 6 Sub 2 |
| Fruit 6 | Farm 4 | 343 | Fruit 6 Sub 1 |
| Fruit 7 | Farm 1 | 935 | Fruit 7 Sub 4 |
| Fruit 7 | Farm 2 | 525 | Fruit 7 Sub 3 |
| Fruit 7 | Farm 3 | 497 | Fruit 7 Sub 2 |
Using a matrix, I want to visualize the top 5 fruit types based on values and then the top 2 sub fruit types. I can get the top 5 Fruit types to be visualized by adding a top N filter to the visual but cant add another Top N filter to the top 2 Fruit Sub Type. How do I proceed?
I would link the file for everyone to see but i dont know how to upload a pbix file here
1 Reply
- amitchandak
Super User
Refer: https://www.sqlbi.com/articles/filtering-the-top-3-products-for-each-category-in-power-bi/
or
Try category or sub-category rank
For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale