Forum Discussion
Filter a Slicer by Table Selection
Hi Anonymous
Your approach is logical, but the issue arises from how Power BI handles context when selecting rows in a table and filtering a slicer. Measures are evaluated dynamically and do not persist selections across different visuals, which is why your slicer filtering is not working as expected. Instead of relying on a measure alone, you can use a disconnected slicer table and a filtering measure that responds to the table selection.
First, create a distinct list of values from your main table that will serve as the slicer options. You can do this with the following DAX formula:
Slicer_Table = DISTINCT(OfflineExcel[Kombi3])
Next, modify the measure that captures the selected values from the table dynamically. This measure ensures that only the selected items from the main table are concatenated into a string:
SelectedValuesMeasure =
VAR SelectedItems = VALUES(OfflineExcel[Kombi3])
RETURN
IF(
NOT ISEMPTY(SelectedItems),
CONCATENATEX(SelectedItems, OfflineExcel[Kombi3], ", "),
BLANK()
)
Now, create a measure that will filter the slicer based on what is selected in the table. This measure checks if the value in the slicer exists in the selected rows of the table and returns 1 if it does:
IsSelected =
IF(
SELECTEDVALUE(Slicer_Table[Kombi3]) IN VALUES(OfflineExcel[Kombi3]),
1,
0
)
Once you have this measure, apply it as a visual-level filter to the slicer and set it to show only values where IsSelected equals 1. This way, the slicer dynamically updates based on the selected rows in the table, reducing the manual effort of searching through slicer options. When a row is clicked, the slicer will only display the relevant selections, making it easier for users to filter and export the desired data efficiently. If no selection is made, the slicer will revert to showing all available options. Let me know if you need further refinements!
Best regards,
- Anonymous1 year agoNot applicable
Hello DataNinja777,
thanks for the rapid response. However, It seems that either I am doing something wrong, or that the solution doesn't do the intended filtering(, probably the first option :D).
So I did that:
And that:
However, the filter does not change a bit when I select Values: My code looks the following way:
Slicer_Table = DISTINCT(OfflineExcel[Artikel-Nr./AAF])I changed the Name, since the Kombi3 is a wired String.
SelectedValuesMeasure_Test = VAR SelectedItems = VALUES(OfflineExcel[Artikel-Nr./AAF]) RETURN IF( NOT ISEMPTY(SelectedItems), CONCATENATEX(SelectedItems, OfflineExcel[Artikel-Nr./AAF], ", "), BLANK() )And Since in your example, you did not use this measure I implemented it in the last bit, but also it your Way.
IsSelected = IF([SelectedValuesMeasure_Test] IN VALUES(OfflineExcel[Artikel-Nr./AAF]), 1, 0)I also did try to create a relationship between both tables, but neither with nor without seemed to work for me.