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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Color Coding with IF in Power BI

I am trying to color code a column in my table with an if statement.   I keep getting an error message.  Any help would be greatly appreciated.  Here is my Dax formula.  

=IF(AND([Calibration Due]]>reportdate,[Calibration Due]]<TODAY()+90),"Due Within 90 Days",IF([Calibration Due]]>TODAY,"In Calibration", IF([Calibration Due]]>TODAY() <> 90, "Green",  IF([Calibration Due]]>TODAY,"Yellow",

"CALIBRATION)

evester_0-1649284084214.png

 

 

4 REPLIES 4
isabella
Microsoft Employee
Microsoft Employee

Hi @Anonymous 

 

you can define your new column like this:

Column = IF(AND([Calibration Due]>TODAY(),[Calibration Due]<TODAY()+90),"Calibration Due",IF([Calibration Due]>TODAY(),"In Calibration","OverDue"))
About the measure,

You can define your measure like this:

 

Measure 1 = IF(MAX('Table (6)'[Calibration Due])>TODAY()+90,"Green",IF(MAX('Table (6)'[Calibration Due])>TODAY(),"Yellow","White"))

 

 

isabella_0-1649645255472.png

 

 

Change the background color by Measure 1

 

isabella_4-1649646124955.pngisabella_5-1649646147090.png

 

 

Visual effect:

 

isabella_2-1649645255473.png

 

 

Best Regards,

Community Support Team _Isabella

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

amitchandak
Super User
Super User

@Anonymous , I think you missed two things. color measure text measure should be separate

example measures

=IF(AND([Calibration Due]]>reportdate,[Calibration Due]]<TODAY()+90),"Due Within 90 Days",IF([Calibration Due]]>TODAY,"In Calibration",
"CALIBRATION"))

 

color =

IF([Calibration Due]]>TODAY() <> 90, "Green", IF([Calibration Due]]>TODAY,"Yellow", "white"))

 

How to do conditional formatting by measure and apply it on pie? : https://youtu.be/RqBb5eBf_I4

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

I am new to Power Query.  I tried to add this column  I am getting error message "Token Literal expected".  Here is my DAX in power query 

= Table.AddColumn(#"Changed Type1", "CalDueFormat", each if [Calibration Due] > Date.From(DateTime.LocalNow()) & if [Calibration Due] < Date.From(DateTime.LocalNow()+ 90 then "Due in 90 Days" else if [Calibration Due] > Date.From(DateTime.LocalNow()) then |
"In Calibration" else "OverDue")

 

The color measure you suggested work but wrong colors appear due to my column I added.  It will not mark the overdue rows. 

Anonymous
Not applicable

I am new to Power Query.  I tried to add this column  I am getting error message "Token Literal expected".  Here is my DAX in power query 

= Table.AddColumn(#"Changed Type1", "CalDueFormat", each if [Calibration Due] > Date.From(DateTime.LocalNow()) & if [Calibration Due] < Date.From(DateTime.LocalNow()+ 90 then "Due in 90 Days" else if [Calibration Due] > Date.From(DateTime.LocalNow()) then |
"In Calibration" else "OverDue")

 

The color measure you suggested work but wrong colors appear due to my column I added.  It will not mark the overdue rows. 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors