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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Apps
Unanswered

Booking time slots

(1) ShareShare
ReportReport
Posted on by 58
Hello everyone,

I have a Power Apps app in which I'm trying to build time slots. To do this, I modified the calendar function. The result should be that I select a date on my calendar (global variable =_dateSelected) and depending on the date selection, the available time slots are displayed to me in a gallery. Then I select a time slot and book it. This time slot disappears in the gallery for the next user (see the attachment). I patch the booked time slots into a sharepoint list, which should be used for comparison with the time slots that have already been booked.
 
I fail at two things:

1. How do I get the calendar day to relate to the gallery? I tried comparing _dateSelected and my values ​​in the Gallery, but that doesn't work. I created the values ​​in the gallery with a collection (see attachment 2).
2. How do I ensure that my collection values ​​and the booked values ​​in the sharepoint list can be compared with each other so that time slots that have already been booked are removed from the gallery?
 
 
Thanks in advance!
 
Sina
 
 
 
I have the same question (0)
  • Jon Unzueta Profile Picture
    1,827 Super User 2025 Season 2 on at
    To achieve your goal of displaying available time slots based on the selected date and ensuring that booked time slots are removed from the gallery, you can follow these steps:
    Step 1: Relate the Calendar Day to the Gallery
    1. Create a Collection for Time Slots:
      • First, create a collection that holds the available time slots for each day. This collection can be created when the app starts or when a date is selected.
    ClearCollect(TimeSlots,
                            {Date: DateValue("2023-04-27"), Time: "09:00 AM"},
                        {Date: DateValue("2023-04-27"), Time: "10:00 AM"},
                              {Date: DateValue("2023-04-27"), Time: "11:00 AM"},
                         {Date: DateValue("2023-04-28"), Time: "09:00 AM"},
                         {Date: DateValue("2023-04-28"), Time: "10:00 AM"}
    );
     
    1. Filter the Gallery Based on Selected Date:
      • Use the Items property of the gallery to filter the time slots based on the selected date.
    Gallery.Items = Filter(TimeSlots, Date = _dateSelected

    Step 2: Compare Collection Values with Booked Values in SharePoint List
    1. Create a Collection for Booked Time Slots:
      • When the app starts or when a date is selected, create a collection that holds the booked time slots from the SharePoint list.
         
    ClearCollect(BookedSlots,
        Filter(SharePointList, Date = _dateSelected)
    );
     
    1. Remove Booked Time Slots from Available Time Slots:
      • Use the RemoveIf function to remove booked time slots from the TimeSlots collection.
    ClearCollect(AvailableSlots,
       RemoveIf(TimeSlots,
            Date = _dateSelected &&
            Time in BookedSlots.Time
        )
    );
      •  
    1. Bind the Gallery to the Available Slots Collection:
      • Set the Items property of the gallery to the AvailableSlots collection.
    Gallery.Items = AvailableSlots

    Example Implementation
    Step-by-Step Code
    1. Create Collections:
    // Create a collection for time slots
    ClearCollect(TimeSlots,
        {Date: DateValue("2023-04-27"), Time: "09:00 AM"},
        {Date: DateValue("2023-04-27"), Time: "10:00 AM"},
        {Date: DateValue("2023-04-27"), Time: "11:00 AM"},
        {Date: DateValue("2023-04-28"), Time: "09:00 AM"},
        {Date: DateValue("2023-04-28"), Time: "10:00 AM"}
    );

    // Create a collection for booked slots from SharePoint list
    ClearCollect(BookedSlots,
        Filter(SharePointList, Date = _dateSelected)
    );

    // Remove booked slots from available time slots
    ClearCollect(AvailableSlots,
        RemoveIf(TimeSlots,
            Date = _dateSelected &&
            Time in BookedSlots.Time
        )
    );
     
    1. Bind the Gallery:
    // Bind the gallery to the available slots collection
    Gallery.Items = AvailableSlots

    Considerations
    • Ensure Data Consistency: Make sure the date format in the TimeSlots collection and the SharePoint list are consistent.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard