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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
PBI-Curious
Resolver I
Resolver I

How to add conditional formatting to Dax measures

PBI Community Good Day!
 
Need to add conditional formatting to the dax measure below.
 
The results will be a net positive number or net negative number, if negative I want the formatting to be red.
 
How can modify dax to include formatting?
 
Net Timing 2 = CALCULATE(
 -1 * SUM( metricssalescustomer[amount] ),
metricssalescustomer[sales_type_lvl1]
    IN { "Lost - Timing", "Decline - Timing", "Upsell - Timing", "New - Timing" }
2 ACCEPTED SOLUTIONS
AUaero
Responsive Resident
Responsive Resident

Conditional formatting is a feature of the visual, not the measure.  If your measure is displayed in a table or matrix, take a look at this link for additional information.

Apply conditional table formatting in Power BI - Power BI | Microsoft Docs

View solution in original post

Seanan
Solution Supplier
Solution Supplier

Hi @PBI-Curious 

I've created a basic example below:

 

Sum = SUM('Values'[Value]) + 0

 

This first code would essentially be your Net Timing 2 function.

Create a second function using the following code:

 

Colour = 
    VAR _SUM = SUM('Values'[Value])
    VAR _Colour = IF(_SUM < 0, "#DB271C", "#73B761")
    return _Colour

 

Replacing the _SUM code with your first function code again.
Now in your visual click on the drop down where your first measure is located and select conditonal formatting.

vloWHKNyYI.png

 

 

 

 

Select background colour -> Change the format style to field value -> Select your colour measure and hit ok.

Any tile with a negative number will now appear red and any non negative numbers will be green.

PBIDesktop_DHiJFOBJn7.pngPBIDesktop_RaofvZdr2y.png

 

 

 

 

View solution in original post

2 REPLIES 2
Seanan
Solution Supplier
Solution Supplier

Hi @PBI-Curious 

I've created a basic example below:

 

Sum = SUM('Values'[Value]) + 0

 

This first code would essentially be your Net Timing 2 function.

Create a second function using the following code:

 

Colour = 
    VAR _SUM = SUM('Values'[Value])
    VAR _Colour = IF(_SUM < 0, "#DB271C", "#73B761")
    return _Colour

 

Replacing the _SUM code with your first function code again.
Now in your visual click on the drop down where your first measure is located and select conditonal formatting.

vloWHKNyYI.png

 

 

 

 

Select background colour -> Change the format style to field value -> Select your colour measure and hit ok.

Any tile with a negative number will now appear red and any non negative numbers will be green.

PBIDesktop_DHiJFOBJn7.pngPBIDesktop_RaofvZdr2y.png

 

 

 

 

AUaero
Responsive Resident
Responsive Resident

Conditional formatting is a feature of the visual, not the measure.  If your measure is displayed in a table or matrix, take a look at this link for additional information.

Apply conditional table formatting in Power BI - Power BI | Microsoft Docs

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.