Forum Discussion
How to use Top N visual filter with Field parameter?
Old thread but I had a similar issue and want to share the solution with others who may be searching.
I have a field parameter linked to a slicer that changes the measure (y axis value) in a column chart.
I wanted to show the top 10 values in the chart for whichever measure was selected by the slicer, but it isn't possible to use the field parameter in the Top N filter. Without the Top N filter there would be far too many values in the chart.
I got it to work by creating a measure using the SWITCH() function as the column in the Top N filter instead (the field parameter is still used as the y axis column).
The syntax of the measure goes like this:
SWITCH_FILTER =
SWITCH(SELECTEDVALUE('slicer_table'[parameter_column]),
"parameter_value_1",[parameter_measure_1],
"parameter_value_2",[parameter_measure_2],
"parameter_value_3",[parameter_measure_3], BLANK())
SWITCH function (DAX) - DAX | Microsoft Learn
- johnt753 years agoSuper User
Interesting. What is the 'slicer table' and how is it related to the field parameter ? It is my understanding that you can't use SELECTEDVALUE directly with the table created for a field parameter.
- PowerBiKing3 years agoFrequent Visitor
Hey - so I have my field parameter table, and a separate 'normal' table that I'm using for the slicer. These tables have a relationship with each other. I didn't set it up as a workaround specifically for the purpose of this solution, I had it like this already because I have one slicer table controlling multiple field parameters.
However I did just test my formula by changing the SELECTEDVALUE part to a column from the field parameter table (instead of the equivalent column in my slicer table) and it does seem to work too.