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
deb_power123
Helper V
Helper V

DAX to compare two Dates and mark the column in Red and NA when the condition doesn't match

Hi All,

 

In my School table i have two columns :- 1) AttendanceLocalDate  2)ServerDate.

 

If AttendanceLocalDate column showing the attendance of students is equal to ServerDate of the attendance serverand the serverDate is equal to systemdate then only it should  populate the values of Attendance localtime, if AttendancelocalDate is not equal to ServerDate[which should also be equal to today's system date], then it should show "NA" with NA text in red color.

 

My Source table :

AttendancelocalDate Location StudentID Name     ServerDate
20.07.2021 11:05AMGate1101Tom20.07.2021 11:05AM
20.07.2021 10.03.22Gate1102Hary20.07.2021 10.03.22
20.07.2021 10.09.21Gate2103Rohan20.07.2021 10.09.21
20.07.2021 09.03.18Gate2105Mohan20.07.2021 09.03.18
19.07.2021 10.08.22Gate2109Sam19.07.2021 10.08.22
19.07.2021 10.03.12Gate2110Sally20.07.2021 10.03.12

 

My expected table matrix:

 

It should populate Attendance total column as NA with red text where the AttendancelocalDate is not equal to serverDate[which should be today's system date only so we need to check this condition as well].Server date also has the potential to show olddates so we need to check it is today's date as the second condition after checking the first condition of AttendancelocalDate equal to Serverdate

 

AttendancelocalDate Location StudentID Name      ServerDate
20.07.2021 11:05AMGate1101Tom20.07.2021 11:05AM
20.07.2021 10.03.22Gate1102Hary20.07.2021 10.03.22
20.07.2021 10.09.21Gate2103Rohan20.07.2021 10.09.21
20.07.2021 09.03.18Gate2105Mohan20.07.2021 09.03.18
NAGate2109Sam19.07.2021 10.08.22
NAGate2110Sally20.07.2021 10.03.12

 

Regards

Sameer

1 REPLY 1
Greg_Deckler
Community Champion
Community Champion

@deb_power123 Try creating two columns. Use the numeric column for your conditional formatting.

Column = 
    SWITCH(TRUE(),
        INT(TODAY()) <> INT([ServerDate]),0,
        [AttendancelocalDate] <> [ServerDate],0,
        1
    )

Column 2 = 
    SWITCH(TRUE(),
        INT(TODAY()) <> INT([ServerDate]),"NA",
        [AttendancelocalDate] <> [ServerDate],"NA",
        [AttendancelocalDate] & ""
    )

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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.