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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

How to create a conditional color for each event on a calendar?

Hello everyone,
I'm trying to create a kind of safety cross, informing the days of the current month, and the color green if there was no accident in that day, red if there was an accident and white for future days. Something like that:

cross.png

 

 

 

 

 

 

 

 

My accident table has this structure:

DateHourDescription
01/13/202017:30:00example
03/08/202013:30:00example
06/29/202003:40:00example


The table only shows the days that had accidents. Any other day that is not in the table, it means that there was no accident.

I tried to create correlated tables, creating a CALENDAR table and linking it with the data column of the accident table, but I couldn't move forward.

Can someone help me?

1 ACCEPTED SOLUTION
nvprasad
Solution Sage
Solution Sage

Hi,

I have created date table and established a relationship and used date from the date table in the visual. I have used the below measure in conditional formatting to apply color where there are some accidents. 

 

conditional_check =
CALCULATE (
COUNTROWS ( Accidents ),
FILTER ( Accidents, SELECTEDVALUE ( Calander[Date] ) = Accidents[Date] ))

 

Add conditional formatting logic where the measure value is higher than 0.

Appreciate a Kudos! 🙂
If this helps and resolves the issue, please mark it as a Solution! 🙂

Regards,
N V Durga Prasad

 

 

View solution in original post

3 REPLIES 3
v-jayw-msft
Community Support
Community Support

Hi @Anonymous ,

 

Create a relationship between tables.

2.PNG

Then create a measure as below.

Measure = IF(SELECTEDVALUE('CALENDAR'[Date])>TODAY(),0,IF(SELECTEDVALUE('CALENDAR'[Date])=SELECTEDVALUE('Table'[Date]),1,2))

At last create conditional formatting.

3.PNG

Result would be shown as below.

4.PNG

 

Best Regards,

Jay

 

Community Support Team _ Jay Wang

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

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
nvprasad
Solution Sage
Solution Sage

Hi,

I have created date table and established a relationship and used date from the date table in the visual. I have used the below measure in conditional formatting to apply color where there are some accidents. 

 

conditional_check =
CALCULATE (
COUNTROWS ( Accidents ),
FILTER ( Accidents, SELECTEDVALUE ( Calander[Date] ) = Accidents[Date] ))

 

Add conditional formatting logic where the measure value is higher than 0.

Appreciate a Kudos! 🙂
If this helps and resolves the issue, please mark it as a Solution! 🙂

Regards,
N V Durga Prasad

 

 

Hi! there is some kind of a step-by-step way to do it please? i tried to do as you said but couldn't move foward..

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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