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 / Struggling with a time...
Power Apps
Unanswered

Struggling with a time slot method

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

bradsnow_0-1606140914512.png

I have an app which allows users to book out spaces using time slots with a drop down, I was trying to make a system where if the user selects a date, area and the time slot they choose is already booked out then the submit button disappears and a "FULL" label appears instead. I was trying to make the system work with 1 hour slots, half days and full days however when I tried to do half days after successfully adding 1 hour slots and full days the formula had some problems in which I struggled to find the root cause.

 

Here is the code I tried on the submit button within the On Visible property:

 

ThisItem.Capacity-CountIf(Bookings_1, Title = ThisItem.Title && DatePicker1.SelectedDate = StartDate && Dropdown2.SelectedText.Value = TimeSlot || Title = ThisItem.Title && DatePicker1.SelectedDate = StartDate && TimeSlot = "08:00 - 17:00" || Title = ThisItem.Title && DatePicker1.SelectedDate = StartDate && Dropdown2.SelectedText.Value = "08:00 - 17:00" || Title = ThisItem.Title && DatePicker1.SelectedDate = StartDate && TimeSlot = "08:00 - 09:00" && Title = ThisItem.Title && DatePicker1.SelectedDate = StartDate && TimeSlot = "09:00 - 10:00" && Title = ThisItem.Title && DatePicker1.SelectedDate = StartDate && TimeSlot = "10:00 - 11:00" && Title = ThisItem.Title && DatePicker1.SelectedDate = StartDate && TimeSlot = "11:00 - 12:00" && Title = ThisItem.Title && DatePicker1.SelectedDate = StartDate && TimeSlot = "13:00 - 14:00" && Title = ThisItem.Title && DatePicker1.SelectedDate = StartDate && TimeSlot = "14:00 - 15:00" && Title = ThisItem.Title && DatePicker1.SelectedDate = StartDate && TimeSlot = "15:00 - 16:00" && Title = ThisItem.Title && DatePicker1.SelectedDate = StartDate && TimeSlot = "16:00 - 17:00")<0 || ThisItem.Capacity-CountIf(Bookings_1, Title = ThisItem.Title && DatePicker1.SelectedDate = StartDate && TimeSlot = "08:00 - 12:00" && Title = ThisItem.Title && DatePicker1.SelectedDate = StartDate && Dropdown2.SelectedText.Value = "08:00 - 09:00" || Title = ThisItem.Title && DatePicker1.SelectedDate = StartDate && Dropdown2.SelectedText.Value = "09:00 - 10:00" || Title = ThisItem.Title && DatePicker1.SelectedDate = StartDate && Dropdown2.SelectedText.Value = "10:00 - 11:00" || Title = ThisItem.Title && DatePicker1.SelectedDate = StartDate && Dropdown2.SelectedText.Value = "11:00 - 12:00")>0

 

If any ideas on fixing the code or even a new way of doing it, help would be greatly appreciated.

 

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    So, before getting to your formula...there is an inherent flaw in your approach to this.  You seem to be storing a text value in the TimeSlot column.  If your time slots are always 1 hour slots, then this can work, but if you plan to go to half days, full days, 30 minutes, etc. This will not work (or at least it would be very time consuming to calculate).  Have you considered instead putting a StartTime and EndTime column in your list?  This would be preferable in order to actually determine availability.  In other words, if your TimeSlot has a "10:00 - 11:00" in it and you try to determine if a room is available for half day ("09:00 - 13:00") you will over book your room.

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Oh right, I tried that way on a copy of the app using this code on the OnSelect property of the submit icon and created StartDate and EndDate as well as a StartDateCalc column: 

     

    ForAll(UserListComboBox_1.SelectedItems, Patch(Bookings_1, Defaults(Bookings_1), {Title:ThisItem.Title, StartDateTime:DateTimeValue(Concatenate(Text(StartDate.SelectedDate), " ", StartHour.SelectedText.Value)),EndDateTime:DateTimeValue(Concatenate(Text(EndDate.SelectedDate), " ", EndHour.SelectedText.Value)), MeetingPOC:Concatenate(UserListComboBox_1.Selected.Surname,", ",UserListComboBox_1.Selected.GivenName," ", UserListComboBox_1.Selected.JobTitle),AttendeesEmail:UserListComboBox_1.Selected.Mail}))

     

    //Patch - Title:ThisItem.Title

    //Patch - StartDateTime:DateTimeValue(Concatenate(Text(StartDate.SelectedDate), " ", StartHour.SelectedText.Value))

    //Patch - EndDateTime:DateTimeValue(Concatenate(Text(EndDate.SelectedDate), " ", EndHour.SelectedText.Value))

    //Patch - MeetingPOC:Concatenate(UserListComboBox_1.Selected.Surname,", ",UserListComboBox_1.Selected.GivenName," ", UserListComboBox_1.Selected.JobTitle)

    //Patch - AttendeesEmail:UserListComboBox_1.Selected.Mail

     

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

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 335 Most Valuable Professional

#2
11manish Profile Picture

11manish 165

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 96 Super User 2026 Season 1

Last 30 days Overall leaderboard