Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
c_banerjee
Frequent Visitor

Conditional formating using DAX

i have created a dax measure to apply conditional formatting however i have the conditions written, but i dont see conditional format anywhere.

Margin Color =
VAR m = SELECTEDVALUE(Total_Sales[Margin])
RETURN
SWITCH(
    TRUE(),
    m < .40, "Orange",  
    m < .50, "Red",  
    m < .60, "Light Green",  
    "Dark green"             
)

However, now that I have the measure, I'm unable to apply it to my margin. I don't know where to find the conditional formatting option or what to do. I could use Microsoft's built-in cell elements, but I don't want to use that; I want to use the DAX condition I created. Where can I find the correct tab to apply my measure?

Thank you
8 REPLIES 8
Prince0011
Continued Contributor
Continued Contributor

Hi,

Your DAX measure looks fine, but whether you can use it for conditional formatting depends on the visual you're using.

A few things to check:

  • Make sure you're using a visual that supports conditional formatting (such as a Table or Matrix).

  • Select the visual, then in the Values well, click the drop-down arrow next to the Margin field and look for Conditional formatting (or Cell elements in newer versions of Power BI).

  • Choose Background color or Font color, then select Format by → Field value and choose your Margin Color measure.

If you don't see the Conditional formatting option:

  • Verify that you're using a Table or Matrix visual, as not all visuals support field-value formatting.

  • Ensure the measure returns valid color names (e.g., "Red", "Orange") or hexadecimal color codes (e.g., #FF0000), which are generally more reliable.

  • Confirm that the field you're formatting is in the Values section of the visual.

Could you let us know:

  • Which visual are you using (Table, Matrix, Card, etc.)?

  • Which version of Power BI Desktop are you using?

  • Are you trying to color the text, the background, or something else?

The Microsoft documentation on conditional formatting may also help:
https://learn.microsoft.com/power-bi/create-reports/desktop-conditional-table-formatting

If you found this reply helpful, please consider giving it a Kudos. If it helps resolve your issue, marking it as the Accepted Solution will help others facing the same problem.

Rupa01
Solution Supplier
Solution Supplier

Hi @c_banerjee

Follow below steps to add conditional formatting -

1. Select the visual and go to Visual formatting Pane > Cell Elements

2. Select the column/field you want to apply conditional formatting

3. Toggle "On" Background color or font color based on your requirement.

Rupa01_1-1784025110696.png

4. A window opens to select the colour options, Select "Field Value" under Format style and select measure created under "What field should we base this on?" (in your case - Margin Color). Click Ok and conditional formatting is applied to the filed choosen.

Rupa01_2-1784025461458.png

 

Sample Example Result - I have applied background color for State column based on Measure.

Rupa01_3-1784025693330.png

 

💡 Helpful? Give a Kudos 👍 — keep the community growing
 Solved your issue? Mark as Solution ✔️ — help others find it faster

Best regards,
Rupasree Achari | BI & Fabric Analytics Engineer 
Rupa01
Solution Supplier
Solution Supplier

@c_banerjee Same measure mentioned I have used for checking Sales in below table and added conditional formatting to Region as below - 

Rupa01_0-1784025990263.png

 

💡 Helpful? Give a Kudos 👍 — keep the community growing
 Solved your issue? Mark as Solution ✔️ — help others find it faster

Best regards,
Rupasree Achari | BI & Fabric Analytics Engineer   

hi @Rupa01 
But now the issue whole column is orange, what im doing wromg here, is there any problem with measure margin color? or measured column total_sales[margin]

@c_banerjee Check the values of the Margin column - if all the values is less than 0.4, < 0.4 condition is satisfying as result orange you are getting.

Please share the sample data or screenshot of the visual or pbix file - if require assistance.

Hi,

Could you kinldy share the download link of the PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
mh2587
Super User
Super User

For a table or matrix visual:

Select your table or matrix visual.
In the Visualizations pane, go to the Values section.
Find the Margin field.
Click the dropdown arrow next to the Margin field.
Select Conditional formatting.
Choose Background color or Font color.
In the dialog box, set Format by to Field value.
In Based on field, select your measure Margin Color.
Click OK.

For a chart (bar, column, etc.):

Select the chart visual.
Open the Format pane.
Expand the Data colors section.
Click the Advanced controls or fx option.
Set Format by to Field value.
Select your measure Margin Color.
Apply the changes.

Important note:
Make sure your measure returns valid color values such as Red, Green, or hex codes like #FF0000.




✔ Answered? Mark as solution

Muhammad Hasnain | Super User • Fabric • Power BI • Data Engineering

Let's connect on LinkedIn

there is format ,build and data pane, format pane has visual and properties, i didnot find anything called data colors, however there is a cell element which has background color selected fx, selected field value  what field should we base this on selected margin color.. what why everything is orange!

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors