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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
masonsmerl17
New Member

Creating conditional color formatting for date column

Hi, 

I want to create a conditional color formatting for the following column:

 

Power BI question.png

Essentially, I want every cell thats date is in the past to have a red background color and every cell that is present or today to have a green background color. I explored the web a bit to figure this out but I am a beginner with power BI and creating a measure was difficult. I ran into a "does not recognize latest start date" notification for the measure I tried to create. This confused me because clearly I have that column in my chart. Anyways, if anyone out there could help walk me through this you would be a life saver. 

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi  @masonsmerl17 ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want.

1. Create a measure as below

Conditional formatting = 
VAR _selsdate =
    SELECTEDVALUE ( 'Table'[Latest Start Date] )
RETURN
    SWITCH (
        TRUE (),
        _selsdate < TODAY (), "Red",
        DATE ( YEAR ( _selsdate ), MONTH ( _selsdate ), DAY ( _selsdate ) ) = TODAY (), "Green"
    )

2. Configure conditional formattingyingyinr_0-1664264803729.png

yingyinr_2-1664264851542.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

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

View solution in original post

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi  @masonsmerl17 ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want.

1. Create a measure as below

Conditional formatting = 
VAR _selsdate =
    SELECTEDVALUE ( 'Table'[Latest Start Date] )
RETURN
    SWITCH (
        TRUE (),
        _selsdate < TODAY (), "Red",
        DATE ( YEAR ( _selsdate ), MONTH ( _selsdate ), DAY ( _selsdate ) ) = TODAY (), "Green"
    )

2. Configure conditional formattingyingyinr_0-1664264803729.png

yingyinr_2-1664264851542.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
JadhavVarsha_13
Resolver II
Resolver II

Hello,

 

You can create a column 

Column = IF('Table name'[Date Column Name]>=TODAY(),1,0)
and then to conditional formatting select as below,
JadhavVarsha_13_0-1664207434441.png

it will give you list of options, select conditional formatting and then select background color,

JadhavVarsha_13_1-1664207516622.png

 

and then Format by - Rules 

Based on field - select column that you have created just now

and then you can add rules here 

JadhavVarsha_13_2-1664207708675.png

 

 

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.