How to Add a Search Box in Power BI
Adding a search box in Power BI allows users to quickly search and filter data within a report or dashboard. Here’s how you can add a search box in Power BI with example code:
Step 1: Prepare Your Data
Make sure your dataset is prepared and loaded into Power BI. You need to have a table or visual that you want to enable searching on.
Step 2: Add a Textbox Visual
1. Open your report or dashboard in Power BI Desktop.
2. From the toolbar, click on the “Textbox” visual under the “Home” tab.
3. Drag and drop the textbox visual to your desired location on the canvas.
Step 3: Configure the Search Functionality
1. Select the textbox visual.
2. In the “Visualizations” pane on the right, go to the “Format” section.
3. Expand the “General” options.
4. Enable the “Search” option by toggling the switch ON.
Step 4: Customize the Search Behavior
1. In the “General” options within the “Format” section, you can customize the search behavior by modifying the following settings:
– Placeholder Text: Set the default text displayed in the search box.
– Search Mode: Choose between “Starts with” or “Contains” to define how the search behaves.
– Case Sensitivity: Toggle ON or OFF to indicate whether the search is case sensitive.
– Clear Text: Enable or disable the “clear text” button next to the search box.
Step 5: Test and Use the Search Box
1. Save and publish your report or dashboard.
2. In the Power BI service, navigate to the published report or dashboard.
3. Interact with the search box by entering keywords to search within the associated table or visual.
Example Code:
Below is an example of HTML code to add a search box in Power BI using a textbox visual:
<div class="search-box">
<input type="text" placeholder="Search..."></input>
</div>