web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Unanswered

Merge multiple arrays/table into a single table/array with common objects having their property added (multiple columns for common row)

(0) ShareShare
ReportReport
Posted on by 27

Hi Community

 

I need help to create an array with data from other arrays. The unique key will be Code rest all may have different values. The Quantity parameter needs to be combined in each row. the Source Data is expected to be Array of 10000 "Array" and each "Array" can have about 100 to 200 objects. The Desired array is supposed to match the object on the basis of "Code" and add "Quantity" property from source array to Desired Output array as Q1, Q2, Q3, Q4, Q5, etc.

 

Source Data Array:

 -------------------------

[
    {
        "Array": [
            {
                "Type": " ",
                "Code": "",
                "Item": "H",
                "Quantity": "1"
            },
            {
                "Type": "",
                "Code": "",
                "Item": "B",
                "Quantity": "2"
            },
            {
                "Type": "HW",
                "Code": "123456",
                "Item": "Test Item1",
                "Quantity": "3"
            },
            {
                "Type": "HW",
                "Code": "789123",
                "Item": "Test Item3",
                "Quantity": "9"
            }
        ]
    },
    {
        "Array": [
            {
                "Type": " ",
                "Code": "",
                "Item": "H",
                "Quantity": "4"
            },
            {
                "Type": "",
                "Code": "",
                "Item": "B",
                "Quantity": "5"
            },
            {
                "Type": "HW",
                "Code": "123456",
                "Item": "Test Item1",
                "Quantity": "3"
            },
            {
                "Type": "HW",
                "Code": "456789",
                "Item": "Test Item2",
                "Quantity": "6"
            },
            {
                "Type": "HW",
                "Code": "789123",
                "Item": "Test Item3",
                "Quantity": "9"
            }
        ]
    },
    {
        "Array": [
            {
                "Type": " ",
                "Code": "",
                "Item": "H",
                "Quantity": "7"
            },
            {
                "Type": "",
                "Code": "",
                "Item": "B",
                "Quantity": "8"
            },
            {
                "Type": "HW",
                "Code": "456789",
                "Item": "Test Item2",
                "Quantity": "6"
            },
            {
                "Type": "HW",
                "Code": "789123",
                "Item": "Test Item3",
                "Quantity": "9"
            }
        ]
    }
]
  -------------------------
 
 
Desired Output:
 -------------------------
[
  {
    "Type": " ",
    "Code": "",
    "Item": "H",
    "Q1": "1",
    "Q2": "4",
    "Q3": "7"
  },
  {
    "Type": "",
    "Code": "",
    "Item": "B",
    "Q1": "2",
    "Q2": "5",
    "Q3": "8"
  },
  {
    "Type": "HW",
    "Code": "123456",
    "Item": "Test Item1",
    "Q1": "3",
    "Q2": "3",
    "Q3": ""
  },
  {
    "Type": "HW",
    "Code": "456789",
    "Item": "Test Item2",
    "Q1": "",
    "Q2": "6",
    "Q3": "6"
  },
  {
    "Type": "HW",
    "Code": "789123",
    "Item": "Test Item3",
    "Q1": "9",
    "Q2": "9",
    "Q3": "9"
  }
]
 -------------------------
 
I have the same question (0)
  • v-jefferni Profile Picture
    on at
    Re: Merge multiple arrays/table into a single table/array with common objects having their property added (multiple columns for common row)

    Hi @Navansh ,

     

    This is the outputs of my test flow:

    vjefferni_0-1689146692863.png

     

    and flow configurations are:

    vjefferni_1-1689146773914.png

    vjefferni_2-1689146826705.png

     

    Outside of Apply to each you can use the variable where contains the array you need.

     

    Best regards,

  • Navansh Profile Picture
    27 on at
    Re: Merge multiple arrays/table into a single table/array with common objects having their property added (multiple columns for common row)

    Hi @v-jefferni 

     

    The actions listed above are applicable to have all the objects in the array but not adding the property to the object.

    The required output is to have limited number of objects with their properties being added:

    Desired Output:
     -------------------------
    [
      {
        "Type"" ",
        "Code""",
        "Item""H",
        "Q1""1",
        "Q2""4",
        "Q3""7"
      },
      {
        "Type""",
        "Code""",
        "Item""B",
        "Q1""2",
        "Q2""5",
        "Q3""8"
      },
      {
        "Type""HW",
        "Code""123456",
        "Item""Test Item1",
        "Q1""3",
        "Q2""3",
        "Q3"""
      },
      {
        "Type""HW",
        "Code""456789",
        "Item""Test Item2",
        "Q1""",
        "Q2""6",
        "Q3""6"
      },
      {
        "Type""HW",
        "Code""789123",
        "Item""Test Item3",
        "Q1""9",
        "Q2""9",
        "Q3""9"
      }
    ]
     
    Updating visualization from array to table:
     
    All Arrays from Source Array:
    Array1:
    TypeCodeItemQuantity
      H1
      B2
    HW123456Test Item13
    HW789123Test Item39
     
    Array2:
    TypeCodeItemQuantity
      H4
      B5
    HW123456Test Item13
    HW456789Test Item26
    HW789123Test Item39
     
    Array3:
    TypeCodeItemQuantity
      H7
      B8
    HW456789TestItem26
    HW789123TestItem39

     

     

    Required Destination Array:

    TypeCodeItemQ1Q2Q3
      H147
      B258
    HW123456Test Item133 
    HW456789Test Item2 66
    HW789123Test Item3999
  • v-jefferni Profile Picture
    on at
    Re: Merge multiple arrays/table into a single table/array with common objects having their property added (multiple columns for common row)

    Hi @Navansh ,

     

    Can't you get the result using the flow I created?

     

    Best regards,

  • Navansh Profile Picture
    27 on at
    Re: Merge multiple arrays/table into a single table/array with common objects having their property added (multiple columns for common row)

    Hi @v-jefferni 

     

    I tried the solution given earlier and it does not give the desired output. what we get is a union of all arrays with these steps:

    Navansh_1-1689573674073.png

     

    Navansh_2-1689573702605.png

     

    Navansh_4-1689573745174.png

     

    JSON Output:

    [
      {
        "Type"" ",
        "Code""",
        "Item""H",
        "Quantity""1"
      },
      {
        "Type""",
        "Code""",
        "Item""B",
        "Quantity""2"
      },
      {
        "Type""HW",
        "Code""123456",
        "Item""Test Item1",
        "Quantity""3"
      },
      {
        "Type""HW",
        "Code""789123",
        "Item""Test Item3",
        "Quantity""9"
      },
      {
        "Type"" ",
        "Code""",
        "Item""H",
        "Quantity""4"
      },
      {
        "Type""",
        "Code""",
        "Item""B",
        "Quantity""5"
      },
      {
        "Type""HW",
        "Code""123456",
        "Item""Test Item1",
        "Quantity""3"
      },
      {
        "Type""HW",
        "Code""456789",
        "Item""Test Item2",
        "Quantity""6"
      },
      {
        "Type""HW",
        "Code""789123",
        "Item""Test Item3",
        "Quantity""9"
      },
      {
        "Type"" ",
        "Code""",
        "Item""H",
        "Quantity""7"
      },
      {
        "Type""",
        "Code""",
        "Item""B",
        "Quantity""8"
      },
      {
        "Type""HW",
        "Code""456789",
        "Item""Test Item2",
        "Quantity""6"
      },
      {
        "Type""HW",
        "Code""789123",
        "Item""Test Item3",
        "Quantity""9"
      }
    ]
     
    Visualization of received output array from suggested solution:
    TypeCodeItemQuantity
      H1
      B2
    HW123456Test Item13
    HW789123Test Ietm39
      H4
      B5
    HW123456Test Item13
    HW456789Test Item26
    HW789123Test Item39
      H7
      B8
    HW456789Test Item26
    HW789123Test Item39
     
     

    Required Destination Array:

    TypeCodeItemQ1Q2Q3
      H147
      B258
    HW123456Test Item133 
    HW456789Test Item2 66
    HW789123Test Item3999
     
  • v-jefferni Profile Picture
    on at
    Re: Merge multiple arrays/table into a single table/array with common objects having their property added (multiple columns for common row)

    Hi @Navansh ,

     

    So, you need a Group by function on the data output from my test flow. Currently I have some issues on my VM so I'm not able to do more test. But I found a blog to perform similar actions on a dataset. Hope it could help.

    Power Automate: Group By Multiple Columns on a Collection (dynamicsforcrm.com)

     

    Best regards,

  • Navansh Profile Picture
    27 on at
    Re: Merge multiple arrays/table into a single table/array with common objects having their property added (multiple columns for common row)

    Hi @v-jefferni 

     

    I have tried the solution given on link powerautomate-groupby-multiple-columns and seem to be stuck as the result is nowhere near the requirement.

    I am sharing screenshots below:

    Navansh_0-1689737693052.png

     

    Navansh_1-1689737772375.png

     

    Navansh_2-1689737901124.png

     

    Navansh_3-1689738003068.png

     

    Navansh_4-1689738316903.png

     

     

  • Matthy79 Profile Picture
    4,178 Super User 2024 Season 1 on at
    Re: Merge multiple arrays/table into a single table/array with common objects having their property added (multiple columns for common row)

    Hello @Navansh 

     

    I would suggest you create a unique array of all the items using union. And after that you use xpath to search the xml converted input JSON to add the information you need.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 647 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 350 Moderator

#3
developerAJ Profile Picture

developerAJ 256

Last 30 days Overall leaderboard