Conditional formatting allows you to change the appearance of visuals based on the values in your data. You can format colors, font, or data bars dynamically using DAX measures to make reports more interactive and highlight important insights.
Using DAX for conditional formatting provides full control over logic beyond the default rules available in Power BI.
Why Use Conditional Formatting
- Highlight key metrics like high sales or low profit
- Make reports visually intuitive
- Draw attention to trends or exceptions
- Support better decision-making
Steps to Use DAX for Conditional Formatting
Step 1: Create a DAX Measure for Formatting
You need a measure that returns a color code or numeric value depending on conditions.
Example 1 โ Color Based on Sales
Sales Color =
IF(
SUM(Sales[Amount]) > 100000,
"#008000", // Green for high sales
"#FF0000" // Red for low sales
)
- Returns a hex color code based on the sales amount.
Example 2 โ Numeric Value for Data Bars
Profit Score =
IF(SUM(Sales[Profit]) > 5000, 1, 0)
- Can be used to determine which bars are highlighted in a visual.
Step 2: Apply Conditional Formatting
- Select the visual (table, matrix, or chart).
- Go to Format > Conditional formatting.
- Choose the type: Background color, Font color, Data bars, or Icons.
- Select Field value as the format option.
- Choose the DAX measure you created.
Step 3: Test and Validate
- Change slicers or filters to see the formatting update dynamically
- Ensure the DAX measure returns correct values for all scenarios
Advanced Example โ Multiple Conditions
Profit Color =
SWITCH(
TRUE(),
SUM(Sales[Profit]) > 10000, "#008000", // Green
SUM(Sales[Profit]) > 5000, "#FFFF00", // Yellow
"#FF0000" // Red
)
- Uses
SWITCH(TRUE())to handle multiple conditions in a clean way - Helps highlight ranges of performance metrics
Best Practices
- Keep colors intuitive (e.g., green for good, red for bad)
- Use dynamic formatting sparingly to avoid overwhelming users
- Test all filter and slicer combinations
- Combine with KPIs and cards for better visual storytelling
Conclusion
Conditional formatting using DAX allows dynamic, rule-based visualization in Power BI. It makes dashboards interactive, highlights critical insights, and ensures reports are visually appealing and easy to interpret.