Efficiently analyse calendar entries

%3CLINGO-SUB%20id%3D%22lingo-sub-2162185%22%20slang%3D%22de-DE%22%3EEfficiently%20analysis%20calendar%20entries%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2162185%22%20slang%3D%22de-DE%22%3E%3CP%3ELet's%20say%20there's%20a%20calendar.%20Typically%20people%20enter%20dates%20there%2C%20which%20are%20rather%20long%20(from%20one%20to%2010%20hours%2C%20typically)%20but%20do%20not%20extend%20over%20more%20than%20a%20day.%20Every%20event%20has%20an%20additional%20field%20(custom%20column%2C%20multiple%20choice%20without%20possibility%20to%20enter%20free%20text)%20holding%20a%20selection%20of%20rooms%20occupied.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20already%20mastered%20reading%20and%20filtering%20calendar%20entries%20by%20different%20means%20(Flow%20filtering%2C%20ODATA%20filtering).%20Now%20I%20want%20to%20build%20a%20flow%20that%20evaluates%20the%20room%20occupancy.%20You%20may%20guess%20the%20purpose.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20output%20should%20be%3A%20another%20calendar%20with%20an%20entry%20for%20every%20hour%20of%20the%20day%20and%20for%20every%20room.%20This%20entries%20will%20have%20the%20column%20for%20the%20rooms%20again%20and%20an%20additional%20numeric%20column%20showing%20the%20number%20of%20people%20in%20that%20room%20at%20the%20same%20time.%20Entries%20with%200%20people%20can%20be%20omitted.%20My%20goal%20is%20to%20visualise%20hourly%20the%20occupancy%20of%20all%20rooms%20respective%20to%20some%20limits.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20want%20my%20flow%20to%20evaluate%20that%20at%20least%20every%20day%20for%20the%20upcoming%2060%20days.%20My%20typical%20approach%20would%20be%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CUL%3E%3CLI%3Einitialise%20array%20for%20one%20day%20(24%20elements%20%3D%200)%3C%2FLI%3E%3CLI%3Efor%20each%20of%20the%20upcoming%2060%20days%3CUL%3E%3CLI%3Efor%20each%20of%20the%20rooms%20load%20all%20events%20(getItems%20filtered%20by%20day%20and%20room)%3CUL%3E%3CLI%3Ereset%20the%20array%20with%2024%20elements%20%3D%200%3C%2FLI%3E%3CLI%3Efor%20each%20date%20from%20GetItems%3CUL%3E%3CLI%3Eiterate%20over%20every%20hour%20from%20StartEvent%20hour%20to%20EndEvent%20hour%3CUL%3E%3CLI%3Eadd%201%20to%20the%20element%20representing%20the%20hour%20in%20the%20array%3C%2FLI%3E%3C%2FUL%3E%3C%2FLI%3E%3C%2FUL%3E%3C%2FLI%3E%3C%2FUL%3E%3C%2FLI%3E%3CLI%3Ewrite%20the%20content%20of%20the%20array%20wherever%20I%20need%20it%20(other%20calender%2C%20excel%20etc.)%3C%2FLI%3E%3C%2FUL%3E%3C%2FLI%3E%3C%2FUL%3E%3CP%3EWe%20see%204%20nested%20loops%2C%20and%20I%20already%20have%20used%20ODATA%20filtering%20to%20reduce%20redundant%20test%20operations%20as%20good%20as%20possible.%20However%2C%20this%20method%20still%20involves%20a%20lot%20of%20loop%20entries%20and%20the%20number%20is%20dependend%20on%20the%20length%20of%20meetings%20in%20the%20calendar.%20I.e.%20A%20date%20needs%20for%20each%20hour%20of%20duration%3C%2FP%3E%3CUL%3E%3CLI%3Ea%20loop%20entry%3C%2FLI%3E%3CLI%3Ea%20test%3C%2FLI%3E%3CLI%3Ea%20increase%20operation%3C%2FLI%3E%3C%2FUL%3E%3CP%3EIf%20I%20want%20to%20improve%20granularity%20by%20testing%20for%20every%2030%20minutes%2C%20the%20number%20of%20actions%20will%20double.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20a%20better%20algorithm%20I%20can%20use%20or%20did%20I%20miss%20some%20nifty%20tricks%20within%20Sharepoint%2C%20ODATA%20or%20operations%20on%20JSON%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2162185%22%20slang%3D%22de-DE%22%3E%3CLINGO-LABEL%3ECalendar%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMicrosoft%20Flow%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharepoint%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
New Contributor

Let's say there's a calendar. Typically people enter dates there, which are rather long (from one to 10 hours, typically) but do not extend over more than a day. Every event has an additional field (custom column, multiple choice without possibility to enter free text) holding a selection of rooms occupied.

 

I already mastered reading and filtering calendar entries by different means (Flow filtering, ODATA filtering). Now I want to build a flow which evaluates the room occupancy. You may guess the purpose.

 

The output should be: another calendar with an entry for every hour of the day and for every room. This entries will have the column for the rooms again and an additional numeric column showing the number of people in that room at the same time. Entries with 0 people can be omitted. My goal is to visualise hourly the occupancy of all rooms respective to some limits. 

 

I want my flow to evaluate that at least every day for the upcoming 60 days. My typical approach would be:

 

  • initialise array for one day (24 elements = 0)
  • for each of the upcoming 60 days
    • for each of the rooms  load all events (getItems filtered by day and room)
      • reset the array with 24 elements = 0
      • for each date from GetItems
        • iterate over every hour from StartEvent hour to EndEvent hour
          • add 1 to the element representing the hour in the array
    • write the content of the array wherever I need it (other calender, excel etc.)

We see 4 nested loops, and I already have used ODATA-Filtering to reduce redundant test operations as good as possible. However, this method still involves a lot of loop entries and the number is dependend on the length of meetings in the calendar. I.e. A date needs for each hour of duration

  • a loop entry
  • a test
  • a increase operation

If I want to improve granularity by testing for every 30 minutes, the number of actions will double. 

 

Is there a better algorithm I can use or did I miss some nifty tricks within Sharepoint, ODATA or operations on JSON?

0 Replies