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
CMSINFO
Frequent Visitor

Conditional formatting for a specific period only

Hi all, I am using conditional formatting as a background colour in each month of the year depending on the value of the field. The problem is that from 2021 I need to change the conditions, i.e., same number could have a different color in 2021, however, I would like to keep the previous colors before 2021, does anybody know if this is feasible?

CMSINFO_0-1618101737842.png

 

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

Hi, @CMSINFO 

What is the name of the chart you are using?

According to your requirement, I think it can be achieved. You can write a measure that uses the IF() function to judge if the date is later than 2021, then used the Switch() function to return color based on value.

You can write a measure like this:

Color=
IF(Year(Max([Date]))=2021,
  Switch(True(),
        [Value]=0,”Green”,
        [Value]>=1&&[Value]<3,”Orange”,
        [Value]>=3,”Red”),
    Switch(True(),
        [Value]=0,”Green”,
        [Value]>=1&&[Value]<5,”Orange”,
        [Value]>=5,”Red”))

Then you can set the conditional format of this chart like this:

v-robertq-msft_0-1618281771823.png

 

Then you can get what you want.

 

If you still have a problem, you can post your sample test pbix file(without sensitive data) and your expected result so that we can help you in advance.

How to Get Your Question Answered Quickly 

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

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

1 REPLY 1
v-robertq-msft
Community Support
Community Support

Hi, @CMSINFO 

What is the name of the chart you are using?

According to your requirement, I think it can be achieved. You can write a measure that uses the IF() function to judge if the date is later than 2021, then used the Switch() function to return color based on value.

You can write a measure like this:

Color=
IF(Year(Max([Date]))=2021,
  Switch(True(),
        [Value]=0,”Green”,
        [Value]>=1&&[Value]<3,”Orange”,
        [Value]>=3,”Red”),
    Switch(True(),
        [Value]=0,”Green”,
        [Value]>=1&&[Value]<5,”Orange”,
        [Value]>=5,”Red”))

Then you can set the conditional format of this chart like this:

v-robertq-msft_0-1618281771823.png

 

Then you can get what you want.

 

If you still have a problem, you can post your sample test pbix file(without sensitive data) and your expected result so that we can help you in advance.

How to Get Your Question Answered Quickly 

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

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

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.

Top Solution Authors