web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Need to validate that ...
Power Apps
Unanswered

Need to validate that many employees of the same deparment dont make leave requests at the same time

(0) ShareShare
ReportReport
Posted on by 8

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.

Categories:
I have the same question (0)
  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Paulo_Dima Try this (change control names as required),

    If(CountIf(LeaveRequest; EmployeeDepartment = _Employee.Department &&
    						 (startDatePicker.SelectedDate>=StartDate ||
    						 endDatePicker.SelectedDate<=EndDate)) > 2;
    "There are many requests in your deparment")

     

     

  • v-albai-msft Profile Picture
    Microsoft Employee on at

    Hi @Paulo_Dima ,

    What do you mean about "at the same time"? I cannot exactly understand the time period for the third Employee.
    If Employee A leaves from day 1 to 5, Employee B from day 4 to 8, there are some possible scenarios for Employee C:
    1. Employee C leaves from day 3 to 6. Do you want to avoid request in this time period?

    2. Employee C leaves from day 28(last month) to 5. Do you want to avoid request in this time period?
    3. Employee C leaves from day 28(last month) to 9. Do you want to avoid request in this time period?

    Or just simply as @CNT  suggested, avoiding new leaving request when the selected time period is both exactly among the two existing time period? If yes, his foormula is correct.

    Best regards,

    Allen

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 325 Most Valuable Professional

#2
11manish Profile Picture

11manish 165

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 88 Super User 2026 Season 1

Last 30 days Overall leaderboard