cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Cazzym
Helper I
Helper I

Efficiently Combining Sorted Arrays into Table

I am contacting an API, that is returning a very large volume of data. I would thus like to avoid using the Apply to Each action to process the data if possible.

 

I have used a toy example below

 

{

   "Column1" : [ 5, 2, 0],

   "Column2" : [ "04-05-2021", "05-05-2021", "06-05-2021" ]

]

 

All columns are correctly ordered by row, all columns are the same length. I would like to combine them into a table format like so.

 

[

{"Column1": 5,

 "Column2": "04-05-2021"

},

{"Column1": 2,

 "Column2": "05-05-2021"

},

{"Column1": 0,

 "Column2": "06-05-2021"

}

]

 

Is this possible without using an iterator and having to loop tens of thousands of times?

1 ACCEPTED SOLUTION

Accepted Solutions
DamoBird365
Community Champion
Community Champion

@Cazzym 

 

If you are looking to do the copy / paste, i introduced an error by renaming my compose without saving - sorry.  Below is the amended working version:

 

{"id":"9c3416b2-19f6-4873-a9b0-9894-a57c20b4","brandColor":"#8C3900","connectionReferences":{},"connectorDisplayName":"Control","icon":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDMyIDMyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg0KIDxwYXRoIGQ9Im0wIDBoMzJ2MzJoLTMyeiIgZmlsbD0iIzhDMzkwMCIvPg0KIDxwYXRoIGQ9Im04IDEwaDE2djEyaC0xNnptMTUgMTF2LTEwaC0xNHYxMHptLTItOHY2aC0xMHYtNnptLTEgNXYtNGgtOHY0eiIgZmlsbD0iI2ZmZiIvPg0KPC9zdmc+DQo=","isTrigger":false,"operationName":"DamoBird365_Repurpose_Array_using_Select","operationDefinition":{"type":"Scope","actions":{"Array_in_Compose":{"type":"Compose","inputs":{"Column1":[5,2,0],"Column2":["04-05-2021","05-05-2021","06-05-2021"]},"runAfter":{}},"Repurpose_Array_using_Select":{"type":"Select","inputs":{"from":"@range(0,2)","select":{"Column1":"@outputs('Array_in_Compose')?['Column1']?[item()]","Column2":"@outputs('Array_in_Compose')?['Column2']?[item()]"}},"runAfter":{"Array_in_Compose":["Succeeded"]}}},"runAfter":{}}}

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

View solution in original post

5 REPLIES 5
DamoBird365
Community Champion
Community Champion

Hey @Cazzym 

 

This would allow you to repurpose your array:

DamoBird365_0-1620113587183.png

 

If you copy and paste the following code into New Step -> My Clipboard, you will get a prebuilt scope with this demo for you to try out and see how it works:

 

{"id":"bb72219e-899a-42af-8471-1eb3-1f159d93","brandColor":"#8C3900","connectionReferences":{},"connectorDisplayName":"Control","icon":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDMyIDMyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg0KIDxwYXRoIGQ9Im0wIDBoMzJ2MzJoLTMyeiIgZmlsbD0iIzhDMzkwMCIvPg0KIDxwYXRoIGQ9Im04IDEwaDE2djEyaC0xNnptMTUgMTF2LTEwaC0xNHYxMHptLTItOHY2aC0xMHYtNnptLTEgNXYtNGgtOHY0eiIgZmlsbD0iI2ZmZiIvPg0KPC9zdmc+DQo=","isTrigger":false,"operationName":"DamoBird365_Repurpose_Array_using_Select","operationDefinition":{"type":"Scope","actions":{"Array_in_Compose":{"type":"Compose","inputs":{"Column1":[5,2,0],"Column2":["04-05-2021","05-05-2021","06-05-2021"]},"runAfter":{}},"Repurpose_Array_using_Select":{"type":"Select","inputs":{"from":"@range(0,2)","select":{"Column1":"@outputs('compose')?['Column1']?[item()]","Column2":"@outputs('compose')?['Column2']?[item()]"}},"runAfter":{"Array_in_Compose":["Succeeded"]}}},"runAfter":{}}}

 

HowToCopyPasteSolution.gif

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

DamoBird365
Community Champion
Community Champion

@Cazzym 

 

If you are looking to do the copy / paste, i introduced an error by renaming my compose without saving - sorry.  Below is the amended working version:

 

{"id":"9c3416b2-19f6-4873-a9b0-9894-a57c20b4","brandColor":"#8C3900","connectionReferences":{},"connectorDisplayName":"Control","icon":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDMyIDMyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg0KIDxwYXRoIGQ9Im0wIDBoMzJ2MzJoLTMyeiIgZmlsbD0iIzhDMzkwMCIvPg0KIDxwYXRoIGQ9Im04IDEwaDE2djEyaC0xNnptMTUgMTF2LTEwaC0xNHYxMHptLTItOHY2aC0xMHYtNnptLTEgNXYtNGgtOHY0eiIgZmlsbD0iI2ZmZiIvPg0KPC9zdmc+DQo=","isTrigger":false,"operationName":"DamoBird365_Repurpose_Array_using_Select","operationDefinition":{"type":"Scope","actions":{"Array_in_Compose":{"type":"Compose","inputs":{"Column1":[5,2,0],"Column2":["04-05-2021","05-05-2021","06-05-2021"]},"runAfter":{}},"Repurpose_Array_using_Select":{"type":"Select","inputs":{"from":"@range(0,2)","select":{"Column1":"@outputs('Array_in_Compose')?['Column1']?[item()]","Column2":"@outputs('Array_in_Compose')?['Column2']?[item()]"}},"runAfter":{"Array_in_Compose":["Succeeded"]}}},"runAfter":{}}}

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

View solution in original post

Hi Damo, works well. Just a note that the range(0,2) should be range (0,3), (why, I have no idea) otherwise works perfectly.

DamoBird365
Community Champion
Community Champion

Hi @Cazzym 

 

Glad you are sorted.  I'm curious about the range?  The integer index for an array starts at 0, therefore as you have 3 keys in each column, the range would run 0,1,2.  What difference do you see between the 0,2 and 0,3 range?

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉


What difference do you see between the 0,2 and 0,3 range?

Looking into it more, range(0,2) only returns [0,1]. So looks like the last value is exclusive, not inclusive.

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Users online (37,587)