Hello and thank you in advance.
I have two sharepoint lists Employee and LeaveRequest. Employee have one column called Department which is the area he is working. LeaveRequest have StartDate, EndDate and EmployeeDepartment. What I need is to know if there are already leave requests of employees of the same department in the date range that the user is selecting for his request.
What I am doing right now is count if there are more than two request registered in the LeaveRequest list which column EmployeeDepartment is the same as the user Department. But my code doesn’t take date in considaration so it compares with every request in the list that have the same department.
I am saving user information in a power apps variable called _Employee. The code I am using at the moment is this:
If(CountIf(LeaveRequest; EmployeeDepartment = _Employee.Department) > 2 ;"There are many requests in your deparment")
What I am trying to avoid is that 3 employees of the same department take days off at the same time. For example, Employee A leaving from day 1 to 5, Employee B from day 4 to 8 and Employee C from day 4 to 5.