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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
jitpbi
Post Patron
Post Patron

background color of card/button visual

Hi,

 

I am not reaching to correct soultion to change the background color of visual based on the below condition:

"On the card visual need to show the background color based on the "Fault" value in the last 1 hour. if the fault value is "True" in the last one hour then it should show red color otherwise it should show green color."

The below is the sample of dataset:

 

DateTimeFault
12/20/2020 10:05:00False
12/20/2020 11:15:00True
12/20/2020 11:15:00False
12/20/2020 09:15:00False

 

Please suggest how to achieve this.

 

Thanks

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@jitpbi , Create this measure, You this measure in conditional formatting with "Field value" option

 

if(isblank(countx(filter(Table[Fault] ="True" && Table[DateTime] >= now() - time(1,0,0) && Table[DateTime] <= now() ),Table[Fault])), "green", "red")

 

refer for step

https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-num...
https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values

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

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@jitpbi , Create this measure, You this measure in conditional formatting with "Field value" option

 

if(isblank(countx(filter(Table[Fault] ="True" && Table[DateTime] >= now() - time(1,0,0) && Table[DateTime] <= now() ),Table[Fault])), "green", "red")

 

refer for step

https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-num...
https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values

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

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors