How to Dynamically Change Power BI Chart Colors Based on User Mode
Question details
The user needs to display a current-temperature chart measure in different colors depending on the selected user mode (e.g., gray for Auto, red/orange for Heat, and blue for Cool).

- Product
- Power BI
- Device & OS
- not provided
- Scenario
- Designing a Power BI dashboard where visual elements must dynamically change color to reflect the active contextual state or operational mode.
- Observed behavior
- By default, the chart displays static data colors. The goal is to bind specific hex color codes to user mode states automatically using conditional formatting.
Ensure your Power BI dataset contains a column or measure that accurately evaluates the current user mode (such as 'Auto', 'Heat', or 'Cool') before applying conditional formatting.
Use a DAX Measure and Conditional Formatting
Create a DAX measure that returns specific hex color codes based on the active user mode, and apply it to your visual's data colors via conditional formatting.
By utilizing the SWITCH function in DAX, you can assign exact hex color codes or standard color names to different data states. This measure is then used to control the visual's formatting dynamically.
In Power BI Desktop, navigate to the Home ribbon and click 'New Measure'. Enter a DAX formula using the SWITCH function. For example: ColorCode = SWITCH(TRUE(), [UserMode]="cool", "#12239E", [UserMode]="heat", "#FF8C00", [UserMode]="fan", "green", "#808080").
Click on the chart on your report canvas where you want to apply the dynamic color coding.
Open the Format pane (paintbrush icon), expand the 'Data colors' or 'Columns/Bars' section, and click the 'fx' (Conditional formatting) button next to the default color.
In the conditional formatting dialog, change the 'Format style' dropdown to 'Field value'. Under 'What field should we base this on?', select the new 'ColorCode' measure you created, and click OK.

Looking for a Lightweight Tool for Everyday Data Visualization?
While Power BI excels at complex DAX logic and large-scale BI reporting, WPS Office provides an incredibly fast and free alternative for everyday data analysis and charting. Perfect for users who need to visualize data quickly without a steep learning curve.
- 1. Open WPS Spreadsheet: Launch WPS Office and open your dataset in WPS Spreadsheet.
- 2. Insert a Chart: Highlight your data range, navigate to the Insert tab, and select your preferred chart type.
- 3. Customize Colors: Click on the chart to reveal Chart Tools, where you can instantly change chart colors and styles using the intuitive formatting pane.

Frequently Asked Questions
Why is the 'fx' conditional formatting button missing in my visual?
Not all visuals in Power BI support conditional formatting for data colors natively. Built-in line charts, scatter charts, and area charts typically restrict this feature. You will need to switch your visual to a column, bar, or table matrix, or download a supported custom visual.
Can I use color names instead of Hex codes in my DAX measure?
Yes, Power BI's conditional formatting recognizes standard HTML color names like "Red", "Blue", or "Green" written inside the DAX strings. However, using Hex codes (e.g., "#FF8C00") gives you precise control over the exact shade displayed on the dashboard.
How do I conditionally format the background of a visual based on the same user mode?
You can reuse the same DAX color measure. Select the visual, go to the Format pane, expand 'Background' or 'Effects', click the 'fx' button next to the background color picker, and select your measure under the 'Field value' formatting style.




