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 / Excluding date range f...
Power Apps
Answered

Excluding date range from overlapping dates control

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,

 

I´m developing a leave request application and ran into a problem. I have a date duplication control (adding code here too). Now I want to make exception for the control when editing request and entering the dates which belonged to the same date range.

 

Current code:

Set(
 _warning,
 IsEmpty(
 Filter(
 Collection, 
 (
 StartDate <= LeaveStartDatePicker.SelectedDate &&
 EndDate > LeaveStartDatePicker.SelectedDate
 ) || 
 (
 StartDate < LeaveEndDatePicker.SelectedDate &&
 EndDate >= LeaveEndDatePicker.SelectedDate
 )
 )
 )
);
If(
 !_warning,
 Reset(LeaveStartDatePicker)
);
Categories:
  • v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    Do you want to reset the Date Pickers if entering the dates which belonged to the date range?

     

    You could try the following formula:

    Set(
     _warning,
     IsEmpty(
     Filter(
     Collection,
     (StartDate>LeaveStartDatePicker.SelectedDate&&StartDate>LeaveEndDatePicker.SelectedDate)
     ||
     (EndDate<LeaveStartDatePicker.SelectedDate&&EndDate<LeaveEndDatePicker.SelectedDate)
     )
     )
    );
    If(
     _warning,
     Reset(LeaveStartDatePicker);Reset(LeaveEndDatePicker)
    )

     

    Best regards,

    If the LeaveStartDate and LeaveEndDate are both less than StartDate, that’s Ok and do not need reset.

    Or if the LeaveStartDate and LeaveEndDate are both larger than EndDate, that’s also Ok.

     

    So, if above conditions are not met, Collection will be empty, and _warning will be “true”. Then it is need to reset Date Pickers.

    vjefferni_0-1668498284281.png

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi, 

     

    Thank you for your reply!

    I would like to exclude dates from the condition that were previously requested. For example, I have requested 10-day leave, from 10th December to 19th December, but now if I want to change the same request but want the end date to be earlier like 15th December. Currently it does not let me because I already have a leave on the same date range, but I want to make exception if I edit request then the control would not trigger on the date range from 10th December to 19th December.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    The formula would include Gallery.Selected.StartDate and EndDate etc.

  • Verified answer
    v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    Please try below formula. The logic is to reset both controls only when the selected dates conflict with other leave request dates:

    vjefferni_0-1668591272766.jpeg

    Set(_warning,If(Gallery.Selected.StartDate<=LeaveEndDatePicker.SelectedDate&&Gallery.Selected.EndDate>=LeaveStartDatePicker.SelectedDate, true ,IsEmpty(Filter(DataSource,StartDate<=LeaveEndDatePicker.SelectedDate&&EndDate>=LeaveStartDatePicker.SelectedDate||LeaveEndDatePicker.SelectedDate<LeaveStartDatePicker.SelectedDate))));
    If(!_warning,Reset(LeaveStartDatePicker);Reset(LeaveEndDatePicker));

     

    You could set "_warning" as "true" to make exception, If value of date pickers belong to range of Gallery.Selected.StartDate and EndDate.

     

    Best regards,

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you!

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 221 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 188 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 120

Last 30 days Overall leaderboard