Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Filter(Sort(col_Desks,Title),Active=1&& Not(// Not reserved for the selected date and time span
Title in Filter(col_Reservations,(DateTimeValue(Text('Check Out From Text',DateTimeFormat.ShortDate)) >=DateTimeValue(Text(startTime,DateTimeFormat.ShortDate))||
DateTimeValue(Text('Check Out To Text',
DateTimeFormat.ShortDate))>DateTimeValue(Text(endTime,DateTimeFormat.ShortDate)))
//&&// Same date)
.Title),MaxCapacity>=CountRows(NameOfPeopleComboBoxNewBooking.SelectedItems)&&MinCapacity<=CountRows(NameOfPeopleComboBoxNewBooking.SelectedItems))
Solved! Go to Solution.
Not working, same error showing both meeting room same time and date.
I have attached the image also please check.
To avoid double bookings for the same time and date in a PowerApp, especially when dealing with resources like meeting rooms or desks, you need to create a logical filter that checks for existing reservations before allowing a new booking. The approach you're taking is generally correct, but let's refine it to ensure it effectively prevents double bookings.
Your current formula is a good start, but it seems a bit complex and might be missing some elements for clarity. The key is to ensure that for any given slot you want to book, there are no existing reservations that overlap with it. Here’s a more streamlined approach:
1. Define the Time Range for the New Booking: You need to have a clear definition of the start and end time for the new booking. Let’s assume `startTime` and `endTime` are your variables holding these values.
2. Filter the Available Slots: You need to filter your `col_Desks` (or any other resource collection) to find those that are not reserved during the specified time range.
3. Check for Overlapping Bookings: The main part of the filter will check for overlapping bookings. A booking overlaps if either:
- It starts before the new booking ends and ends after the new booking starts.
- It starts and ends within the new booking time frame.
Here is a simplified version of the formula that you might use:
Filter(
col_Desks,
Active = 1,
Not(
Title in Filter(
col_Reservations,
(DateTimeValue(Text(CheckOutFrom, DateTimeFormat.ShortDate)) < DateTimeValue(Text(endTime, DateTimeFormat.ShortDate))
&&
DateTimeValue(Text(CheckOutTo, DateTimeFormat.ShortDate)) > DateTimeValue(Text(startTime, DateTimeFormat.ShortDate)))
).Title
),
MaxCapacity >= CountRows(NameOfPeopleComboBoxNewBooking.SelectedItems),
MinCapacity <= CountRows(NameOfPeopleComboBoxNewBooking.SelectedItems)
)
In this formula:
- `CheckOutFrom` and `CheckOutTo` should be fields in your `col_Reservations` collection that indicate the start and end times of existing bookings.
- `DateTimeValue(Text(..., DateTimeFormat.ShortDate))` is used to ensure that the times are correctly formatted and comparable.
This formula assumes:
- `col_Desks` is your collection of bookable resources.
- `col_Reservations` is your collection of existing bookings.
- `MaxCapacity` and `MinCapacity` are fields in `col_Desks` that define the capacity limits for the resource.
Remember, PowerApps formulas can be quite sensitive to syntax and context, so you might need to adjust this based on your specific app's design and data structure. Always test thoroughly to ensure it handles all booking scenarios correctly.
Proud to be a Super User!
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
24 | |
13 | |
12 | |
11 | |
8 |
User | Count |
---|---|
42 | |
26 | |
14 | |
14 | |
12 |