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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
deb_power123
Helper V
Helper V

DAX to compare with system date and find attendance dates for today

Hi All,

 

I have a table named school  as shown below . Here Attendance dates columns are populated on a daily basis.It can also contain old records sometimes but we need to mark them as NA and red color in the cell of the tabular matrix in powerBI

 

As per my requirement if the attendance date is not equal to the systemdate then it should show NA and mark the cell as red dynamically. Say today is "15.07.2021" then the third row has entry "14.07.2021 10.09.21" this cell needs to be filled with red color with text NA replacing "14.07.2021 10.09.21".

 

Could anyone please suggest any DAX to handle this situation?

 

 Attendance  Date swipeLocation StudentID Name
15.07.2021 11:05AM    Gate1    101   Tom
15.07.2021 10.03.22   Gate1    102   Hary
14.07.2021 10.09.21   Gate2    103  Rohan
15.07.2021 09.03.18   Gate2    105 Mohan
15.07.2021 10.08.22   Gate2    109   Sam
15.07.2021 10.03.12   Gate2    110   Sally

 

Kind regards

Sameer

1 ACCEPTED SOLUTION

Hi @deb_power123

 

In that condition you can update measure with below code:-

 

check_dates = IF(MAX(Attendance[Attendancelocal Date]) = MAX(Attendance[ServerDate]),FORMAT(MAX(Attendance[Attendancelocal Date]),"m/dd/yyyy hh:mm:ss AM/PM"),"NA")

 

 

Add below measure in conditional formating under "Font Color" 

 

 

Formating_Measure = IF([check_dates] = "NA","red")

 

 

Samarth_18_0-1626834275172.png

 

Samarth_18_2-1626834471476.png

 

You will get below output:-

Samarth_18_3-1626834856859.png

 

 

Thanks

 

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

3 REPLIES 3
Samarth_18
Community Champion
Community Champion

Hi @deb_power123 

You can create two measure one for checking dates and another for conditional formating.

- Create a measure with below code for checking date with today

check_date = IF(MAX(Attendence_Table[ Attendance  Date]) < NOW(),"NA",FORMAT(MAX(Attendence_Table[ Attendance  Date]),"mm/dd/yyyy hh:mm:ss"))

 

- Create a measure with below code and use it conditional formating

Format_Measure = IF([check_date] = "NA","red")

 PFB screenshot

Samarth_18_0-1626399595627.png

Thanks

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Thankyou @Samarth_18  for the above DAX. I am really sorry , i missed an important point.In my table i have two columns :- 1) AttendanceLocalDate  2)ServerDate

If AttendanceLocalDate column is equal to ServerDate then only it should fetch populate the values of Attendance localtime, if it is not equal to ServerDate [server date should be again equal to system date always]it should show as per the below expected  in table matrix

 

My Source :

Attendancelocal DateLocationStudentIDNameServerDate
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[server date should be always today's system date , this check should also be done] so we have 2 checks here.Today's system date is 20.07.2021

Attendancelocal Date Location StudentIDName 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

Hi @deb_power123

 

In that condition you can update measure with below code:-

 

check_dates = IF(MAX(Attendance[Attendancelocal Date]) = MAX(Attendance[ServerDate]),FORMAT(MAX(Attendance[Attendancelocal Date]),"m/dd/yyyy hh:mm:ss AM/PM"),"NA")

 

 

Add below measure in conditional formating under "Font Color" 

 

 

Formating_Measure = IF([check_dates] = "NA","red")

 

 

Samarth_18_0-1626834275172.png

 

Samarth_18_2-1626834471476.png

 

You will get below output:-

Samarth_18_3-1626834856859.png

 

 

Thanks

 

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.