Forum Discussion
Anonymous
8 years agoNot applicable
Top N as a dynamic filter
Hello all, I want to create a slicer for top N products by sales. I need a filter which has values: 1) top1-10 2) top 10-20 3) top 20-30 Whenever the user clicks on any of the three the pr...
- 8 years ago
Hi Anonymous,
1. Create a table like below. Do not establish relationship with other tables.
Rule ID
top 1 - 10 1 top 10 - 20 2 top 20 - 30 3 2. Create a measure like below.
rankColorName = VAR rankShouldBe = RANKX ( ALL ( DimProduct[ProductName] ), CALCULATE ( SUM ( FactSales[SalesQuantity] ) ) ) RETURN IF ( HASONEFILTER ( ruleTable[Rule] ), IF ( MIN ( ruleTable[ID] ) = 1 && rankShouldBe <= 10, rankShouldBe, IF ( MIN ( ruleTable[ID] ) = 2 && rankShouldBe > 10 && rankShouldBe <= 20, rankShouldBe, IF ( MIN ( ruleTable[ID] ) = 3 && rankShouldBe > 20 && rankShouldBe <= 30, rankShouldBe, BLANK () ) ) ), rankShouldBe )3. Create a table visual and a slicer like below.
Best Regards,
Dale
Pulkit
Resolver I
8 years agoYou can use RANKX and bookmarks to achieve this.
Create the visual, then in the visual level filter do the basic filtering to select only the ranks 1-10 (I am assuming you will give 1st rank to the highest sales), then bookmark it. Do the same for TOP N = 11-20 and 21-30.
After creating the three bookmarks add them to buttons. This is not filter but it will do the the job.