power-automatepower-platform

Join the outcomes of multiple FilterArray Power Automate actions without using ApplytoEach


I am doing multiple API calls inside an Apply To each, to get data from the same external API but for different date/time. Then I am doing the following:-

  1. RemoveSOAPTAgs from the API call response
  2. Convert the outcomes to XML
  3. Convert the XML to JSON
  4. Parse the JSON
  5. Filter the JSON
  6. Loop through the result of the FilterJSON-IncludeUser and append the items inside an array named "jointJson"

enter image description here

The above is working in respect to functionalities, where i will get all the JSON from all the API calls inside the "JointJson" array. but it is taking time, mainly on the "Apply to each 3" where i am building the "JointJson" array + the workflow is consuming many actions beyond the threshold limit i can have which is 48,000 calls each 24 hours.

So my question is , is there a way to join the result of the FilterJSON-IncludeUser actions inside the ApplyToEach without having to loop through the result and use ApendToArray?

The result of the "FilterJSON-IncludeUser" will be as follow:-

{"body":[{"@Id":"19267384","@AgentId":"11**","@CallDuration":"0:00:49","@CallOrigin":"Outbound - Manual","@CallSegment":"Initial","@CallTime":"12/2/2024 5:51:30 AM","@Campaign":"Affiliate","@ContactId":"42***74","@Group":"Openers","@InboundPhone":"","@LeadFullName":"Dj*** T***","@LeadId":"42***","@ProspectPhone":"+1***","@RecordingUrl":"","@Result":"Conversation","@TargetNumber":"+1 5***","@User":"****","@WaitTime":"","@CallId":"2****"},{"@Id":"19267387","@AgentId":"11657","@CallDuration":"0:00:35","@CallOrigin":"Outbound - Manual","@CallSegment":"Initial","@CallTime":"12/2/2024 5:52:54 AM","@Campaign":"Affiliate","@ContactId":"428***","@Group":"Openers","@InboundPhone":"","@LeadFullName":"**","@LeadId":"4286***","@ProspectPhone":"+*****","@RecordingUrl":"","@Result":"Conversation","@TargetNumber":"+1 ***","@User":"****","@WaitTime":"","@CallId":"C***7"}]}

or it will be empty.

any advice?

Thanks


Solution

  • This seems too simple but the Union function can help you here.

    https://learn.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#union

    However, take note ... it will remove duplicates, it only stores the unique items so if you do have some kind of duplicate thing happening, that may be your downfall.

    You will need to Compose the arrays together first and then use Set variable to set JointJson from the output of the Compose step. I’m sure you already know that you can’t self reference in variable setting.