Forum Discussion
Nested Top N using Power BI DAX
Hi, rashmi_panicker
Because the context of the matrix is complex, and the value of measure changes according to the results in the filter pane, it is not possible to simply filter.
With my efforts, I made this perfect solution, hope you can give me a kudos.
Total rank measure:
Rank = IF ( ISINSCOPE ( 'Table'[Category] ), RANKX ( FILTER ( ALL ( 'Table' ), [Manufacturer] = SELECTEDVALUE ( 'Table'[Manufacturer] ) ), CALCULATE ( MAX ( 'Table'[Sales] ) ) ) , IF ( ISINSCOPE ( 'Table'[Manufacturer] ), RANKX ( SUMMARIZE ( ALL ( 'Table' ), [Manufacturer], "total", SUM ( 'Table'[Sales] ) ), CALCULATE ( SUM ( 'Table'[Sales] ) ), )) )Column for rank category:
rankcategory = RANKX(FILTER(ALL('Table'),[Manufacturer]=EARLIER('Table'[Manufacturer])),[Sales])I created a column because I can't use two topns in the filter pane.
Below is my sample. If you don't understand anything, feel free to ask me.
Janey
12 Replies
- amitchandakSuper User
rashmi_panicker , refer if this blog can help
https://www.sqlbi.com/articles/filtering-the-top-3-products-for-each-category-in-power-bi/
- rashmi_panickerFrequent Visitor
Thank you for your response Amit. But, I have already tried this example and have mentioned the same url in my post above. I am able to reach to a point where I am able to rank my Categories and Products properly using this sqlbi.com post. But, when I try to add filter on the Rank column, I don't get the required data.
- v-janeyg-msftCommunity Support
Hi, rashmi_panicker
I don't know what your formulas and data look like, it's hard to give you substantial help.
Can you share some sample data and your desired result? So we can help you soon.
Janey