Hi @SectorOMEGA ,
I have an Idea based on your description, you'd like to display only the current booking and the next upcoming booking based on the current time. Since you have the time slots in button labels and they are stored in SharePoint as text (e.g., "12:00 - 13:00"), you can achieve this with a combination of filtering and sorting.
Here's how you can approach it:
ClearCollect(
BookingData,
SharePointList
)
Now create a new column in your collection to convert the text time slots to actual time values. For example:
ForAll(
BookingData,
Patch(
BookingData,
Defaults(BookingData),
{
ChosenTimeSlot: Text(
TimeValue(Mid(ChosenTimeSlot, 1, 5)),
"[$-en-US]hh:mm tt"
)
}
)
)
Filter and sort the collection to get the current and upcoming booking:
Set(
CurrentTime,
Now()
);
ClearCollect(
FilteredBookings,
Sort(
Filter(
BookingData,
ChosenTimeSlot >= CurrentTime
),
ChosenTimeSlot,
Ascending
)
)
Now, you can use the FilteredBookings collection to display the current booking and the next upcoming booking.
- For the current booking: Use First(FilteredBookings) to get the first record in the collection.
- For the next upcoming booking: Use If(CountRows(FilteredBookings) > 1, FilteredBookings[1]) to get the second record if it exists.
Please mark my post as solution if it helps you. And please don't forget to give an Appreciation Thupm Up.
Cheers!