cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
PGTips
Level: Powered On

Schedule view merged with events from a calendar

I have a collection which contains events in 30 minute or 1 hour blocks.

It looks like this:

Collection = Schedule (which has 1 column, scheduleID.....this is the ID of the calendar)

Sub Collection = Schedule.scheduleItems (which has 3 columns, Status, Start.datetime, End.datetime)

 

I can display all the events in a gallery just fine - but I need to add rows into the collection to fill out all the slots which don't have an event. 

E.g: 

 

09:00 - 09:30 = Busy (because there is an event in the above collection)

09:30 - 10:00 = Free (because no events match this time slot) <-------this is what I need to generate

10:00 - 10:30 = Busy (because there is an event in the above collection)

etc.....

So how would you create those empty time slots? Am I going the right way using a Gallery?

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Microsoft v-siky-msft
Microsoft

Re: Schedule view merged with events from a calendar

@PGTips 

Are all events 30 minutes apart? What is the time interval of the events? Could you please share more detailed designs?

Based on the information available, I've made a demo that might meet your needs. I assume all events are 30 minutes apart and from 9:00 to 11:00.

1. first to create a Time interval collection to save all possible Time intervals. You can put this code to Button OnSelect property for test.

 

ClearCollect(Col_TimeInterval,{Start:"9:00",End:"9:30"},{Start:"9:30",End:"10:00"},{Start:"10:00",End:"10:30"},{Start:"10:30",End:"11:00"})

 

2. expand the subgallery, use ForAll function to loop through to see if a time interval does not exist and if so, add it to the collection, re-group at the end of the loop.

 

ClearCollect(Col_expand,Ungroup(Schedule,"scheduleItems"));ForAll(Col_TimeInterval,ForAll(Schedule,If(IsEmpty(Filter(Col_expand,scheduleID=Schedule[@scheduleID] && StartDateTime=Start && EndDateTime=End)),Patch(Col_expand,Defaults(Col_expand),{scheduleID:Schedule[@scheduleID],StartDateTime:Start,EndDateTime:End,Status:"Free"}))));ClearCollect(ScheduleV2,GroupBy(Col_expand,"scheduleID","scheduleItems"))

 

3. Then the ScheduleV2 is the collection that fills out all the slots which don't have an event. 

Snipaste_2020-02-11_15-10-49.png

I also attach the demo app, please find the attachments.

Sik

 

View solution in original post

1 REPLY 1
Microsoft v-siky-msft
Microsoft

Re: Schedule view merged with events from a calendar

@PGTips 

Are all events 30 minutes apart? What is the time interval of the events? Could you please share more detailed designs?

Based on the information available, I've made a demo that might meet your needs. I assume all events are 30 minutes apart and from 9:00 to 11:00.

1. first to create a Time interval collection to save all possible Time intervals. You can put this code to Button OnSelect property for test.

 

ClearCollect(Col_TimeInterval,{Start:"9:00",End:"9:30"},{Start:"9:30",End:"10:00"},{Start:"10:00",End:"10:30"},{Start:"10:30",End:"11:00"})

 

2. expand the subgallery, use ForAll function to loop through to see if a time interval does not exist and if so, add it to the collection, re-group at the end of the loop.

 

ClearCollect(Col_expand,Ungroup(Schedule,"scheduleItems"));ForAll(Col_TimeInterval,ForAll(Schedule,If(IsEmpty(Filter(Col_expand,scheduleID=Schedule[@scheduleID] && StartDateTime=Start && EndDateTime=End)),Patch(Col_expand,Defaults(Col_expand),{scheduleID:Schedule[@scheduleID],StartDateTime:Start,EndDateTime:End,Status:"Free"}))));ClearCollect(ScheduleV2,GroupBy(Col_expand,"scheduleID","scheduleItems"))

 

3. Then the ScheduleV2 is the collection that fills out all the slots which don't have an event. 

Snipaste_2020-02-11_15-10-49.png

I also attach the demo app, please find the attachments.

Sik

 

View solution in original post

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (7,583)