Power BI Table Highlight Row Based on Value
In this article
Yes, you can highlight a specific row in a Power BI table visual using Conditional Formatting, and it is a built-in feature that requires no custom code. To achieve this, you must use a measure that returns a boolean value (true or false) to determine if the row meets your criteria, and then apply that measure as the conditional formatting rule. This visual cue helps analysts quickly spot specific data points, such as sales figures that exceed a target, or inventory levels that are critically low.
What You'll Need
- A Power BI Desktop file or a service workspace (Power BI Service) containing your data model and reports.
- A table visual already created on your report canvas.
- A basic understanding of your data model, specifically which table and columns you want to use for the highlighting criteria.
- Access to the Power BI Desktop ribbon or the Power BI Service formatting pane.
Step-by-Step
- Create or open your report. Launch Power BI Desktop, open your report file, or navigate to the relevant workspace in the Power BI Service. Ensure you are in the report editing mode.
- Add a table visual. Drag a table visual from the Visualizations pane onto your report canvas. Add the columns you wish to display. This provides the context for your highlighting rule.
- Identify the criteria. Decide exactly what value or condition will trigger the row highlight. Common examples are: "Is this product's sales greater than 10,000?", "Is this region's inventory below 50 units?", or "Is the status 'Overdue'?".
- Create a measure. Go to the Modeling tab in the Power BI Desktop ribbon and select New Measure. In the formula bar, enter your DAX expression that returns a TRUE or FALSE result based on your chosen criteria. For example, to highlight sales over 10,000, you might write:
Highlight High Sales = IF([Sales Amount] > 10000, TRUE(), FALSE()). This measure is the key to the entire process. - Apply conditional formatting. With your table visual selected, go to the Format your visual pane. Look for the section labeled Conditional formatting. Click on the dropdown arrow and select Field Value.
- Select the measure. In the dropdown menu that appears, select the measure you created in step 4. The table will now update, and rows where the measure returns TRUE will be highlighted by the default color (usually blue).
- Customize the appearance. Click on the colored box representing the highlight color to open the formatting options. You can change the background color, text color, or even the border. To make the highlight more distinct, you might choose a bright color like orange or red and a dark text color.
- Apply the rule to other visuals (optional). If you have other visuals, such as a card or a matrix, that display the same data, you can apply the same conditional formatting rule to them by selecting the visual and repeating the process from step 5.
Common Mistakes
The most frequent error is attempting to highlight a row based on a static value or a column directly, rather than a measure. Power BI's conditional formatting on tables is designed to work with field values, not with static numbers. If you try to highlight a row where the "Sales Amount" column is greater than 10,000, it will not work as expected because there is no built-in way to compare a field value to a static number per row in a table. You must always create a measure that performs this comparison.
Another common mistake is not saving the report after making changes. In Power BI Desktop, your changes are not automatically saved. Forgetting to save will result in losing all your work, especially if the application crashes or you close the file without saving.
Finally, users often fail to test their measure. A simple syntax error in a DAX measure will result in an error message and no highlighting. It is crucial to check the measure in a card visual first to ensure it returns a TRUE or FALSE value for the rows you are interested in.
Tips
For more advanced highlighting, consider using the Top/Bottom values conditional formatting option. This allows you to highlight the top 10% of rows based on a specific measure, which is useful for quickly identifying outliers. For example, you could highlight the top 10% of products by sales amount.
Using a Star Rating visual can be a great alternative to a table for highlighting. You can create a measure that returns a star rating based on your criteria, and then use that measure to create a visual that is both informative and easy to read. This is particularly useful when you want to show a qualitative assessment of the data.
When creating your measure, keep it simple. Complex DAX expressions can be difficult to debug and may not work as expected in conditional formatting. If you need to perform complex logic, break it down into smaller measures and then combine them in a final measure.
Troubleshooting
If the conditional formatting does not appear to be working, the first step is to verify that your measure is returning a TRUE or FALSE value. Select your table visual and go to the Format your visual pane. Look for the section labeled Conditional formatting. Click on the dropdown arrow and select Field Value. You should see your measure listed in the dropdown menu. If it is not there, check your measure's syntax in the formula bar for any errors. You can also test your measure in a card visual to confirm it returns the expected result.
If your measure is correct and is listed, but the highlighting is not happening, check the formatting options. Ensure that the background color is set to a color other than white or transparent. Also, ensure that the rule is applied to the correct field or measure. If you are using a matrix visual, ensure that the conditional formatting is applied to the background of the entire row, not just a single cell.
If you are using Power BI Service, the issue might be related to caching. Try refreshing your report by clicking the Refresh button in the Home ribbon. If that does not work, try closing and reopening the report.
Frequently Asked Questions
Can I highlight a row based on a specific date?
Yes. You can create a measure that checks if the date in your table is a specific date or falls within a specific date range. For example, .
Why is my measure not showing up in the conditional formatting dropdown?
If your measure is not showing up, it may not be in the table visual's data fields. Ensure that you have added the measure to the Values field well of the table visual. The conditional formatting rule must be based on a field that is currently displayed in the visual.
Can I use conditional formatting to highlight multiple rows?
Yes. By creating a measure that returns TRUE for multiple rows, you can highlight all of them. For example, if you want to highlight all products that are in the category "Electronics", you would create a measure that checks the category column and returns TRUE for all rows where the category is "Electronics".
How do I remove conditional formatting?
To remove conditional formatting, select the visual and go to the Format your visual pane. Under Conditional formatting, click on the dropdown arrow and select None. This will remove the formatting and return the visual to its default state.
Does conditional formatting work on slicers?
No, conditional formatting is not available for slicers in Power BI. You can only apply conditional formatting to visuals such as tables, matrices, cards, and gauges.
Can I highlight a row based on a text value?
Yes. You can create a measure that uses the SEARCH or CONTAINSSTRING functions to check if the text in your table contains a specific word or phrase. For example, Highlight Specific Text = IF(CONTAINSSTRING([ProductName], "Pro"), TRUE(), FALSE()).