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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
DivakarKrishna
Frequent Visitor

DAX to return non-existing records for the specific date filter

Dear Team,

 

I have a requirement to display the records where they don't have punch-in for the specific day.

 

I wrote the below DAX only for today,  and it's working perfectly.

 

DAX for Today only :-

Check Employee =
IF (
COUNTROWS(
EXCEPT(
VALUES(PBI_WFC_Emp_Master[employeeId]),
CALCULATETABLE(
VALUES(PBI_WFC_Time_Attendance[employeeId]),
USERELATIONSHIP(PBI_WFC_Emp_Master[employeeId],PBI_WFC_Time_Attendance[employeeId]),
PBI_WFC_Time_Attendance[Punch In Date]=TODAY()
)
)
)>0,1,0)
 
Instead of Today, I want the date to be dynamic by whichever date was chosen from the date slicer, So I wrote the below DAX but it's not working properly, it's returning all records which is incorrect.
 
DAX for selected date from slicer:
Check Employee =
VAR _date = ALLSELECTED('Calendar'[Date])
RETURN
IF (
COUNTROWS(
EXCEPT(
VALUES(PBI_WFC_Emp_Master[employeeId]),
CALCULATETABLE(
VALUES(PBI_WFC_Time_Attendance[employeeId]),
USERELATIONSHIP(PBI_WFC_Emp_Master[employeeId],PBI_WFC_Time_Attendance[employeeId]),
PBI_WFC_Time_Attendance[Punch In Date]=  _date
)
)
)>0,1,0)
 
Can you please suggest me on how to fix this above DAX? I want the non-existing records selected by the specific date (01/25 or 01/26 etc... )
 
Thanks,
P.K.Divakar
4 REPLIES 4
amitchandak
Super User
Super User

@DivakarKrishna , Try like

VAR _date = Maxx(ALLSELECTED('Calendar'), 'Calendar'[Date])

 

and rest is same

Hi Amit bro @amitchandak ,

 

Tried this one already, but not working.. When I select date in date slicer, table returns blank value.

 

Check Employee =
VAR _date = MAXX(ALLSELECTED('Calendar'),'Calendar'[Date])
RETURN
IF (
COUNTROWS(
EXCEPT(
VALUES(PBI_WFC_Emp_Master[employeeId]),
CALCULATETABLE(
VALUES(PBI_WFC_Time_Attendance[employeeId]),
USERELATIONSHIP(PBI_WFC_Emp_Master[employeeId],PBI_WFC_Time_Attendance[employeeId]),
PBI_WFC_Time_Attendance[Punch In Date]= _date
)
)
)>0,1,0)
 
 
DivakarKrishna_0-1643356686856.png

 

@DivakarKrishna , Try like

 

Check Employee =
VAR _date = MAXX(ALLSELECTED('Calendar'),'Calendar'[Date])
RETURN
IF (
COUNTROWS(
EXCEPT(
VALUES(PBI_WFC_Emp_Master[employeeId]),
summarize(filter(CALCULATETABLE(PBI_WFC_Time_Attendance,
USERELATIONSHIP(PBI_WFC_Emp_Master[employeeId],PBI_WFC_Time_Attendance[employeeId]) )
PBI_WFC_Time_Attendance[Punch In Date]= _date),PBI_WFC_Time_Attendance[employeeId])
)
)
>0,1,0)

 

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Hi @amitchandak ,

 

Can you please share your email id, so i can share sample .pbix file?

 

Thanks!

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors