Forum Discussion
tanehome1
1 year agoHelper I
filtering data with multiple keywords parameters
I need a DAX to search multiple keywords to filter data. In my case, I would need to filter with OR operation, meaning that all rows that include any of the keywords are shown.
user can write one, two or three words in the text box to search with.
thanks in advance.
10 Replies
- rohit1991Super User
Hi, tanehome1 ,
Use a calculated column or measure to filter rows based on multiple keywords entered by the user.
Solution: DAX Measure for Dynamic Filtering
SearchFilter = VAR SearchText = SELECTEDVALUE('SearchTable'[SearchInput], "") RETURN IF( SEARCH(SearchText, 'YourTable'[YourColumn], 1, 0) > 0, 1, 0 )- Replace 'YourTable'[YourColumn] with the column you want to search in.
- This works for one keyword entered by the user.a
Solution: Support Multiple Keywords
For multiple keyword searches, use multiple SEARCH conditions:
SearchFilter = VAR Keywords = SUBSTITUTE(SELECTEDVALUE('SearchTable'[SearchInput], ""), " ", "|") RETURN IF( SUMX( FILTER( ADDCOLUMNS( GENERATESERIES(1, LEN(Keywords) - LEN(SUBSTITUTE(Keywords, "|", "")) + 1), "Word", PATHITEM(Keywords, [Value], "|") ), SEARCH([Word], 'YourTable'[YourColumn], 1, 0) > 0 ), 1 ) > 0, 1, 0 )- This allows users to enter multiple words, separated by spaces.
- The measure checks if any keyword exists in the column.
- tanehome1Helper I
thanks a lot for your reply.
just need to understand the use of
'SearchTable'[SearchInput]
and to replace with what?
- mark_endicottSuper User
tanehome1 - Replace that with the column containing the key words you wish to filter on
- tanehome1Helper I
it should be dynamicaly entered by user in the text slicer !!