Forum Discussion
Creating a dynamic slicer
Hi, I created a field parameter and on the left side are the 6 fields that I've set up. On my right side is a filter ("Choose Track(s)").
I want that when the user clicks on each button, the description changes to "Choose Album(s)", "Choose Artist", etc.
I can create a measure that does that but I can't seem to create a way that changes the slicer to use the field as specified, when the user clicks a button
I used a switch dax measure but that didn't help. Here's my code
The error I'm getting is that the fields that are in bold, are not recognized, unelss I aggregate them, which would not make sense in a slicer.
Any ideas on how to resolve this? My goal is to have one slicer on the page no matter which metric the user clicks on.
Thanks, Steven Taub
Hi StevenT
If you're meaning to change the slicer header, you can conditionally format it using a measure that responds to the selected value of the Parameter Order column.
Slicer Title = SWITCH ( SELECTEDVALUE ( Parameter[Parameter Order] ), 0, "Text", 1, "Text2" )- Anonymous1 year ago
Hi StevenT ,
Do you want to select column names in Slicer1 and show values of selected column in Slicer2?
If so, please refer to the method in message 3, that may be what you want.
Best regards,
Mengmeng Li
8 Replies
- StevenTHelper V
Actually I found a way to do it that didn't require much coding. Please take a look at this link and tell me what you think? It worked perfectly for me.
https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Power-BI-Power-BI-Create-Dynamic-Slicers-using-Field-Parameters/m-p/2960735- danextianSuper User
You lost me there. Weren't you already usnig field parameters as you said you created one and you just wanted the title/header in the second slicer to be dynamic?
- AnonymousNot applicable
Hi StevenT ,
I'm afraid you'll need to create a custom table for dynamic slicer, because in Power BI, slicers are typically used to filter data, and they're mostly used with column fields, not measures. The measure is the result of a dynamic calculation and cannot be used directly as a field in the slicer.
1. Use Union to combine all the columns in the parameter and their corresponding order into a new table.
Table 2 = DISTINCT(UNION(ADDCOLUMNS(SELECTCOLUMNS('Album',"Field",'Album'[Album]),"Order",0),ADDCOLUMNS(SELECTCOLUMNS('Artist',"Field",'Artist'[Artist]),"Order",1))) //Add other fields as Album and Artist.2. Add "one to many" relationship between parameter and custom table.
3. Use "Field" column in dynamic slicer. Then the slicer will show selected column values when you select parameter slicer.
4. If you want dynamic slicer to filter origianl tables, you can create relationships between them.
5. For the changed title of dynamic slicer.
Measure = SWITCH(SELECTEDVALUE(Parameter[Parameter Order]),0,"Choose Album",1,"Choose Artist")Here is my test and attached pbix file for your reference. I am showing value of Table[Date] and Table(2)[Test1] in dynamic slicer.
Best regards,
Mengmeng Li
- StevenTHelper V
Thanks for this. I have been able to change the title with no difficulty, it's what I want to do with the data source, that I've run into a challenge.
Any ideas about the data source? - AnonymousNot applicable
Hi StevenT ,
What do you want to do with the data source? If you want to use parameter to dynamically change data sources in visuals, you can refer to my reply in this post. Solved: Dynamic API call - Microsoft Fabric Community
Best regards,
Mengmeng Li