Showing results for 
Search instead for 
Did you mean: 

Join arrays efficiently without using loops in Power Automate

Use Case

Usually, we come across the problem of joining the arrays. One most common case is "left join" where resultant array contains the matched values and if second array does not have the matching value then it stores blank or empty value in the final result. I will show you the way to perform left join without using nested loops with a real case scenario.


Scenario & Sample data

In an education institution, there are pre booked walk-in appointments scheduled for 30 minutes duration slot for students. The admin shared the full day schedule with the required recipients. Here is the sample booking slots for 23rd Oct 2023:


When we directly fetch the events in Power Automate using "Get", we will get the list of events which are scheduled for that day but does not return the blank slots when there is no appointment. We will generate the full day appointment list in this example.



1. Create a new scheduled cloud flow and set the occurrence as per the requirement. Here, I have set up the flow to run daily at 9:30 am:


Click on the Recurrence action and set the time zone, start hours & minutes.:



2. Add Compose action that stores all possible start time of 30 duration event during business hours. Here, I have considered the business hours from 10:00 am to 5:00 pm, you may modify it as per your need:


Please note that I have used 13:00 - 14:00 as lunch timings in the above screenshot.



3. Add "Get calendar view of events" action to fetch the events. Choose the Calendar Id from the drop-down list. To get the current date event. we need to write an expression in the "Start Time" & "End Time" parameter:


Expression used for Start Time:


Expression used for End Time:



4. Add Select action to create an array of StartTime & Subject from the output of get events action. Pass the value object from the output of 'Get calendar view of events' action. Expression needs to be written for converting UTC to local time zone and get the value in HH:mm format:


Expression used for StartTime property; you may modify the target time zone as per your need:

convertTimeZone(item()?['start'],'UTC','India Standard Time','HH:mm')


5. Add another Select action which will perform the left join operation. Pass the output of Compose action (contains all possible start time for a day) in "From" parameter. For both map properties, expression needs to be written in the expression box:


Expression used in the above screenshot:

Key Value
Time item()
Appointment if(greater(length(xpath(xml(json(concat('{"Root":{"Item":',body('Select'),'}}'))),concat('//StartTime[text()=','''',item(),'''',']/..'))),0),json(xml(base64ToString(first(xpath(xml(json(concat('{"Root":{"Item":',body('Select'),'}}'))),concat('//StartTime[text()=','''',item(),'''',']/..')))?['$content'])))?['Item/Subject'],if(equals(item(),'13:00'),'No Appointments - Lunch',''))

Expression used in Appointment value lookup for the time value present in the output array from Select action. If found, it gets the corresponding subject & set it in Appointment column. In nested if condition, it checks for lunch timings (13:00) & accordingly returns the value.


6. Next, add Create HTML table action & pass the output of 'Select 2' action in the "From" parameter:



7. Finally, add "Send an email" action, set the email subject & recipients. Pass the output of "Create HTML table" action to the body of email. I have used an expression to create a border for html table in email body:


Expression used for creating border in html table:

replace(body('Create_HTML_table'),'<table>','<table border="1">')



The result of the flow execution will look like:




As you have seen in this blog, it is possible to join arrays using Select action & fx expressions. We should avoid using loops or "Apply to each" action in joining or comparing arrays especially with large elements exists in the arrays. I hope that this tutorial would help you in using the above technique where joining of arrays is required.


About the Author
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • I am a Microsoft Business Applications MVP and a Senior Manager at EY. I am a technology enthusiast and problem solver. I work/speak/blog/Vlog on Microsoft technology, including Office 365, Power Apps, Power Automate, SharePoint, and Teams Etc. I am helping global clients on Power Platform adoption and empowering them with Power Platform possibilities, capabilities, and easiness. I am a leader of the Houston Power Platform User Group and Power Automate community superuser. I love traveling , exploring new places, and meeting people from different cultures.
  • Read more about me and my achievements at: MCT | SharePoint, Microsoft 365 and Power Platform Consultant | Contributor on SharePoint StackExchange, MSFT Techcommunity
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • Founder of SKILLFUL SARDINE, a company focused on productivity and the Power Platform. You can find me on LinkedIn: and twitter I also write at, so if you want some Power Automate, SharePoint or Power Apps content I'm your guy 🙂
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 15 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • Big fan of Power Platform technologies and implemented many solutions.
  • Passionate #Programmer #SharePoint #SPFx #M365 #Power Platform| Microsoft MVP | SharePoint StackOverflow, Github, PnP contributor
  • Web site – Youtube channel -