Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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
Solved! Go to Solution.
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")
You will get below output:-
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
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
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 Date | Location | StudentID | Name | ServerDate |
20.07.2021 11:05AM | Gate1 | 101 | Tom | 20.07.2021 11:05AM |
20.07.2021 10.03.22 | Gate1 | 102 | Hary | 20.07.2021 10.03.22 |
20.07.2021 10.09.21 | Gate2 | 103 | Rohan | 20.07.2021 10.09.21 |
20.07.2021 09.03.18 | Gate2 | 105 | Mohan | 20.07.2021 09.03.18 |
19.07.2021 10.08.22 | Gate2 | 109 | Sam | 19.07.2021 10.08.22 |
19.07.2021 10.03.12 | Gate2 | 110 | Sally | 20.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 | StudentID | Name | ServerDate |
20.07.2021 11:05AM | Gate1 | 101 | Tom | 20.07.2021 11:05AM |
20.07.2021 10.03.22 | Gate1 | 102 | Hary | 20.07.2021 10.03.22 |
20.07.2021 10.09.21 | Gate2 | 103 | Rohan | 20.07.2021 10.09.21 |
20.07.2021 09.03.18 | Gate2 | 105 | Mohan | 20.07.2021 09.03.18 |
NA | Gate2 | 109 | Sam | 19.07.2021 10.08.22 |
NA | Gate2 | 110 | Sally | 20.07.2021 10.03.12 |
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")
You will get below output:-
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
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
25 | |
10 | |
7 | |
6 | |
6 |
User | Count |
---|---|
30 | |
11 | |
11 | |
10 | |
6 |