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 / Datetime based filteri...
Power Apps
Unanswered

Datetime based filtering for reservation app

(1) ShareShare
ReportReport
Posted on by 25

Please I need assistance with my guest room reservation application. I want to prevent users from booking or reserving rooms during time slots that have already been approved. This is my code below. I am working with two datasources; Rooms(sharepoint list containing the list of rooms which is filtered based on the selected location) and colBooking(Which is a collection of a sharepoint list called Reservations containing the start and end datetime and also the approval status). What am i doing wrong here please?

 

Filter(
Rooms,
Location.Value = varSelectedLocation &&
IsBlank(
LookUp(
colBookings,
Room.Value = Title &&
'Approval Status'.Value = "Approved" &&
!(DateTimeValue(Text(DatePickerStart.Value) & " " & Text(TimeValue1.Selected.Value) & ":" & Text(MinuteValue1.Selected.Value) & ":00") >= End ||
DateTimeValue(Text(DatePickerEnd.Value) & " " & Text(TimeValue2.Selected.Value) & ":" & Text(MinuteValue2.Selected.Value) & ":00") <= Start)
)
)
).Title

Categories:
  • Pro_User_365 Profile Picture
    546 on at

    Hi  @ElectroWiz, 

    The formula you've provided aims to filter available rooms that are not already booked for a given time slot. However, the logic within the LookUp function seems inverted. You want to check for existing bookings that conflict with the desired time slot and ensure they don't overlap with the new booking request. Here's a revised version of the formula:

    Filter(
     Rooms,
     Location.Value = varSelectedLocation &&
     IsEmpty(
     Filter(
     colBookings,
     Room.Value = Title &&
     'Approval Status'.Value = "Approved" &&
     Start < DateTimeValue(Text(DatePickerEnd.Value) & " " & Text(TimeValue2.Selected.Value) & ":" & Text(MinuteValue2.Selected.Value) & ":00") &&
     End > DateTimeValue(Text(DatePickerStart.Value) & " " & Text(TimeValue1.Selected.Value) & ":" & Text(MinuteValue1.Selected.Value) & ":00")
     )
     )
    ).Title
    Note: After receiving the answer, if you think it's helpful, please consider accepting it. 😊 Regards! Ali Shahzad
     
  • ElectroWiz Profile Picture
    25 on at

    I tried it but it didn't work. Maybe my initial code's logic is way off. So basically, in my reservations list(colBooking), i have a column called meetingroom of type text which stores the Room selected by a user when it is submitted. Does this make any difference? I'm fairly new to powerapps

  • Pro_User_365 Profile Picture
    546 on at

     @ElectroWiz, 

    Certainly! If you have a column named "meetingroom" in your reservations list (colBooking) that stores the selected room when a user submits a reservation, you can use this information to filter available rooms more effectively. Here's a revised formula:

    Filter(
     Rooms,
     Location.Value = varSelectedLocation &&
     IsBlank(
     LookUp(
     colBookings,
     meetingroom = Title && 'Approval Status'.Value = "Approved" &&
     !(DateTimeValue(Text(DatePickerStart.Value) & " " & Text(TimeValue1.Selected.Value) & ":" & Text(MinuteValue1.Selected.Value) & ":00") >= End ||
     DateTimeValue(Text(DatePickerEnd.Value) & " " & Text(TimeValue2.Selected.Value) & ":" & Text(MinuteValue2.Selected.Value) & ":00") <= Start)
     )
     )
    ).Title

    This formula checks if the selected room (meetingroom) matches the room title, and it verifies that there are no overlapping approved bookings for that room during the requested time slot. This should help you prevent users from booking rooms during time slots that have already been approved.

     

  • ElectroWiz Profile Picture
    25 on at

    Unfortunately this did not work too. Still showing a room that has been booked and approved for a particular time slot as available 😞

  • CU18061035-1 Profile Picture
    Microsoft Employee on at

    please try this:

     

    Please I need assistance with my guest room reservation application. I want to prevent users from booking or reserving rooms during time slots that have already been approved. This is my code below. I am working with two datasources; Rooms(sharepoint list containing the list of rooms which is filtered based on the selected location) and colBooking(Which is a collection of a sharepoint list called Reservations containing the start and end datetime and also the approval status). What am i doing wrong here please?
    
     
    
    Filter(
    Rooms,
    Location.Value = varSelectedLocation &&
    IsBlank(
    LookUp(
    colBookings,
    Room.Value = Title &&
    'Approval Status'.Value = "Approved" &&
    !(DateTimeValue(Text(DatePickerStart.Value) & " " & Text(TimeValue1.Selected.Value) & ":" & Text(MinuteValue1.Selected.Value) & ":00") >= End ||
    DateTimeValue(Text(DatePickerEnd.Value) & " " & Text(TimeValue2.Selected.Value) & ":" & Text(MinuteValue2.Selected.Value) & ":00") <= Start)
    )
    )
    ).Title

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

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 243 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 204 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 122

Last 30 days Overall leaderboard