Today I was asked how to implement a booking availability solution in Power Apps.
The booking availability app
Table of Contents
So I’m looking to create an app that will ask the user for some booking details, a start date and an end date for the booking period. Once you user has supplied those details we need to know if the slot is available or not.
You could sue this for calendar management in for example a room booking solution.
I’ve created an app in Power Apps that looks like this:

On the right I’m listing all the existing bookings and on the right I’m asking for the details and checking for the availability of my requested booking slot..
The data layer
I’m using SharePoint to store all my bookings in a list. In my list I’ve created two bookings already.

So now we need to look at the code behind that button in the app.
Check the booking availability
So we have two date pickers in the app. One collects the from date and the other one collects the to Date
I will start by checking the number of day that is covered bin the period between the from and to dates. This can be done using the following line of code:
Set(varDays,DateDiff(DatePickerFrom.SelectedDate,
DatePickerTo.SelectedDate,TimeUnit.Days)+1);
Now I’m going to generate a range of numbers starting with 0
Set(varSequence, Sequence(varDays,0,1));
The above should result in an array like 0,1,2,3 if there are 3 days between the two dates given. Notice that I need to include both the start and end date in this array. Hence the +1 earlier.
Compare the Booking slot with the existing bookings
Now we need to check the availability by going through all the dates in the requested period. If we find any of these dates covered by any of the records already in the bookings list then we have to reject the booking.
Set(varAllChecks,
ForAll(varSequence,
CountRows(Filter(Bookings,
'Start Date' <= DateAdd(DatePickerFrom.SelectedDate, Value,TimeUnit.Days)
And
'End Date' >= DateAdd(DatePickerFrom.SelectedDate, Value,TimeUnit.Days)))
));
This will now give us an array telling us how many records were found for each date in the date range. So for an available period we should just get an array with 0s.
Now we need to count the not 0s found in the array using the following line of code:
Set(varAvailable, CountRows(Filter(varAllChecks, Value <>0))=0)
The Full Code
The overall code behind the button should now look like this.
Set(varDays,DateDiff(DatePickerFrom.SelectedDate,
DatePickerTo.SelectedDate,TimeUnit.Days)+1);
Set(varSequence, Sequence(varDays,0,1));
Set(varAllChecks,
ForAll(varSequence,
CountRows(Filter(Bookings, 'Start Date' <= DateAdd(DatePickerFrom.SelectedDate, Value,TimeUnit.Days) And 'End Date' >= DateAdd(DatePickerFrom.SelectedDate, Value,TimeUnit.Days)))
));
Set(varAvailable, CountRows(Filter(varAllChecks, Value <>0))=0)
Hi, great post, it helped me a lot, but could you advise me how to implement in it also for example a place that would compare to the place the user chooses or rather places when it will be multichoice and that it would check if these places are available for reservation or not.
Best regards
In the new request form you would need to ask for the place that the user wants to place a booking. Then include that place in a filter action around the Bookings data source.
if i write Místo = DatacardValue3.selectedItems;Value to filter it did not work. Could you help me please?
Is Misto holding single place?
Try :
Misto in DatacardValue3.selectedItems.Value
Misto is the name of column in sharepoint
Set(varAllChecks;
ForAll(varSequence;
CountRows(Filter(‘Rezervace SASLABU’;
‘Rezervace od’ = DateAdd(DateValue1.SelectedDate; Value;TimeUnit.Days)
And
Místo in DataCardValue3.SelectedItems.Value
))
));;
i tried this one and i have the error: “invalid argument type of table value cannot be used in this context” and error is in the “Místo”
When I looked at the title I thought you were going to integrate Microsoft Bookings into Powerapps. Do you think this is possible somehow because Bookings is already great but it would be even better if we could integrate this in our personal apps
When there is an API there is integration possible.
When there’s a Microsoft Graph API, it is quite easy to integrate.
https://learn.microsoft.com/en-us/graph/api/resources/booking-api-overview?view=graph-rest-1.0
Misto is the name of column in sharepoint and it is multiple choice column
Set(varAllChecks;
ForAll(varSequence;
CountRows(Filter(‘Rezervace SASLABU’;
‘Rezervace od’ = DateAdd(DateValue1.SelectedDate; Value;TimeUnit.Days)
And
Místo in DataCardValue3.SelectedItems.Value
))
));;
i tried this one and i have the error: “invalid argument type of table value cannot be used in this context” and error is in the “Místo”
Hi David,
It looks like you have the in operation the wrong way around.
DataCardValue3.SelectedItems.Value in Místo
Hello Pieter,
when I tried your code, I seem to get an error DataCardValue3.SelectedItems.Value in Misto: the error is in the value section and it says that the invalid type of the table value argument cannot be used in this context.
I would like to create a check to see if there are double bookings for selected places. This means checking if the Places I have selected from the drop down list are not already booked for the date I have selected.