Forum Discussion
Filter slicer using multiple selections that are substrings
Hi,
I am trying to build a slicer that allows multiple selections from dropdown which then filters out the dataset based on the selections.
getting a single selection was quite easy by using:
VAR _Concat = CONCATENATEX(VALUES('Product'[Products]),'Product'[Products],",")
RETURN IF(_Count>2,"Multiple Selection",_Concat)
Hi Anonymous ,
In this case you need to do a different setup use the following measure:
Product selected exists = VAR SplitByCharacter = "," VAR ProductTableSelection = SELECTCOLUMNS ( ADDCOLUMNS ( GENERATE ( SELECTCOLUMNS ( Solution_Products; "Find_Text"; Solution_Products[SolutionProducts] ); VAR TokenCount = PATHLENGTH ( SUBSTITUTE ( [Find_Text]; SplitByCharacter; "|" ) ) RETURN GENERATESERIES ( 1; TokenCount ) ); "Product_selection"; PATHITEM ( SUBSTITUTE ( [Find_Text]; SplitByCharacter; "|" ); [Value] ) ); "Products_Selected"; [Product_selection] ) RETURN IF ( COUNTROWS ( FILTER ( ALLSELECTED ( Products ); FORMAT ( Products[Product]; "#" ) IN ProductTableSelection ) ) = COUNT ( Products[Product] ); "Yes"; "No" )
5 Replies
- MFelixSuper User
Hi Anonymous ,
One option can be to use the following code:
Product selected exists = IF( SUMX(Products; FIND( UPPER(Products[Product]); UPPER(SELECTEDVALUE(Solution_Products[SolutionProducts])) ;;0 ) ) > 0; "Yes"; "No" )Has you can see below the values are filtered out:
You can now use the measure has a filter on your visualizations you can also replace the No by blank.
PBIX file attach.
- AnonymousNot applicable
Hi Miguel,
Thank you for this. This is definitely a lot closer.
thre is 1 thing that I need to change on here. Your code filters based on 'OR' so that if I select 4 and 6, rows 2,3,and 4 appear. However, I need the filter to be an 'AND' so that only row 3 should say "Yes"
Many thanks,
Marc
- MFelixSuper User
Hi Anonymous ,
In this case you need to do a different setup use the following measure:
Product selected exists = VAR SplitByCharacter = "," VAR ProductTableSelection = SELECTCOLUMNS ( ADDCOLUMNS ( GENERATE ( SELECTCOLUMNS ( Solution_Products; "Find_Text"; Solution_Products[SolutionProducts] ); VAR TokenCount = PATHLENGTH ( SUBSTITUTE ( [Find_Text]; SplitByCharacter; "|" ) ) RETURN GENERATESERIES ( 1; TokenCount ) ); "Product_selection"; PATHITEM ( SUBSTITUTE ( [Find_Text]; SplitByCharacter; "|" ); [Value] ) ); "Products_Selected"; [Product_selection] ) RETURN IF ( COUNTROWS ( FILTER ( ALLSELECTED ( Products ); FORMAT ( Products[Product]; "#" ) IN ProductTableSelection ) ) = COUNT ( Products[Product] ); "Yes"; "No" )