Forum Discussion
Dynamic Selection with Dynamic Top N
Hi KMcCarthy9 ,
I have built data sample:
Assume:
FT = CALCULATE(SUM('Table'[Value]),ALLEXCEPT('Table','Table'[Suppliers]))RT = CALCULATE(AVERAGE('Table'[Value]),ALLEXCEPT('Table','Table'[Suppliers])) SDR = CALCULATE(MEDIAN('Table'[Value]),ALLEXCEPT('Table','Table'[Suppliers]))
Then please follow these steps:
1. Enter a Type table, the values are all of your measure names:
2. Create a measure to match the type name and measure like this:
Measure = SWITCH(MAX('Type'[Type]),"FT",[FT],"RT",[RT],"SDR",[SDR])
3. Add a what-if paremeter:
4. Create a flag measure for filter later:
Flag =
var _min=MIN('TopN'[TopN])
var _max=MAX('TopN'[TopN])
var _rank=RANKX(ALL('Table'),CALCULATE ( [Measure] ),,DESC,Dense)
return IF(_rank>=_min && _rank<=_max,1,0)
5. Finally create a matrix visual as shown below:
Output:
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- KMcCarthy94 years ago
Helper V
Thank you for this Anonymous as it is very interesting!
I can't quite get the TopN selector to work properly.
Also, would it be possible to have the end user select one of the 'types' from a slicer and the Top N number and have the matrix still show all the data in the other type columns but only show the Top N of the 'type' that is selected.
For example, the output for Top 3 for FT would look like this:
I have attached a sample pbix file here: pbix file
Thank you for your help!