Let me break this down step by step.
First, you need to create a search box in Power BI. This is done by creating what's called a "What-if Parameter":
- Go to
Modeling > New Parameter
- Choose
Text as the parameter type
- Name it something like "Search Box" (this will create a table called 'Search Box' with a column also called 'Search Box')
- Check "Add slicer to this page" - this creates the actual search box on your report
Now, here's the measure you need, with the correct names and detailed explanation:
Keyword Filter =
VAR SearchTerm = LOWER(TRIM('Search Box'[Search Box])) // Gets what user types in search box
VAR CurrentKeywords = LOWER(SELECTEDVALUE('YourTable'[Keywords])) // Gets keywords from your Keywords column
RETURN
IF (
ISBLANK(SearchTerm), // If search box is empty
1, // Show all rows
IF (
CONTAINSSTRING(CurrentKeywords, SearchTerm), // Does "Keyword1,Keyword2..." contain what user typed?
1, // Yes - show this row
0 // No - hide this row
)
)
Let's break down what each part does:
-
VAR SearchTerm = LOWER(TRIM('Search Box'[Search Box]))
- Gets what the user typed in the search box
- Makes it lowercase
- Removes any extra spaces
- If user types "GLOVE " it becomes "glove"
-
VAR CurrentKeywords = LOWER(SELECTEDVALUE('YourTable'[Keywords]))
- Gets the keywords from your Keywords column
- Makes them lowercase
- If your column contains "Gloves,Hands" it becomes "gloves,hands"
-
The IF statements:
IF (
ISBLANK(SearchTerm), // Is search box empty?
1, // Yes - show everything
IF ( // No - check if keywords match
CONTAINSSTRING(CurrentKeywords, SearchTerm),
1, // Found a match - show row
0 // No match - hide row
)
)
To use this:
- Create the measure exactly as above (adjust table/column names to match yours)
- Select your table/matrix/visual
- In the Filters pane, drag this measure
- Set it to show only when the value is 1
Now when someone types in the search box:
- Empty search box = shows all rows
- Type "glove" = shows any row where the Keywords column contains "glove"
- Type "hand" = shows any row where the Keywords column contains "hand"
The search is not case sensitive and will find partial matches (e.g., typing "glo" will find "gloves").
Would you like me to show you how to make this even more powerful (like searching for multiple terms at once)?