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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Split incoming array i...
Power Automate
Unanswered

Split incoming array into two different arrays

(0) ShareShare
ReportReport
Posted on by

Hi all, array question here. I have a button in Power BI that brings in data, which I put into an array via compose. An entry in the resulting array looks like this:

Spoiler (Highlight to read)
    {
        "Field 1""1234",
        "Field 2""5678 - Name1 - Name2",
        "Field 3""OPEN",
        ...
        "Field8"2022,
        "Field9": "1/2/3/4",
        "Field10"3,
        "Field11"String"
 },
etc.
    {        "Field 1": "1234",        "Field 2": "5678 - Name1 - Name2",        "Field 3": "OPEN",        ...        "Field8": 2022,        "Field9": "1/2/3/4",        "Field10": 3,        "Field11": String" },etc.

I'd like to split the array in two, so I get one array that contains fields 1-7 and a second one that contains fields 8-11, then add a GUID created earlier in the flow into each so I can link them together if necessary.

 

I tried something like creating two array variables, and then loading data into one or the other with an "apply to each" to the original array, but I wasn't able to get it to work. I'm still new enough to Power Automate that I'm still trying to understand the data operations. Is this doable?

Categories:
I have the same question (0)
  • SudeepGhatakNZ Profile Picture
    14,394 Most Valuable Professional on at

    SudeepGhatakNZ_0-1692844133469.png

     

    SudeepGhatakNZ_1-1692844149799.png

     

    Output:

    SudeepGhatakNZ_2-1692844182293.png

     

  • Community Power Platform Member Profile Picture
    on at

    Hi @SudeepGhatakNZ - thanks so much for the detailed response! I think I'm 90% of the way there, just getting a couple remaining errors. My Parse JSON step looks like the following:

    RMDSPC_1-1692893096485.png

    RMDSPC_3-1692893176430.png

     

    However, both of the Append to Array steps at the end throw this error:

    RMDSPC_2-1692893127085.png

    I'm assuming it's a problem with my Parse step. Do I need to run a Apply To Each to loop through the array? What am I missing?

  • SudeepGhatakNZ Profile Picture
    14,394 Most Valuable Professional on at

    If your Parse JSON step is returning an array, shouldn't the Append step be inside a loop?

    Are you able to share the entire output of your Compose PBI Data to array action?

     

     

  • Community Power Platform Member Profile Picture
    on at

    Hi @SudeepGhatakNZ,

     


    @SudeepGhatakNZ wrote:

    If your Parse JSON step is returning an array, shouldn't the Append step be inside a loop?


    I wouldn't know, that's the kind of thing I'm trying to figure out by asking. 

     

    When the Power BI trigger is hit, it returns this: 

    Spoiler (Highlight to read)
    {
      "type""object",
      "properties": {
        "rows": {
          "type""array",
          "items": {
            "type""object",
            "properties": {
              "entity": {
                "type""object",
                "properties": {
                  "Power BI values": {
                    "title""Power BI data",
                    "type""array"
                  }
                },
                "required": [
                  "Power BI values"
                ]
              }
            },
            "required": [
              "entity"
            ]
          }
        }
      },
      "required": [
        "rows"
      ]
    }
    {  "type": "object",  "properties": {    "rows": {      "type": "array",      "items": {        "type": "object",        "properties": {          "entity": {            "type": "object",            "properties": {              "Power BI values": {                "title": "Power BI data",                "type": "array"              }            },            "required": [              "Power BI values"            ]          }        },        "required": [          "entity"        ]      }    }  },  "required": [    "rows"  ]}

    I use the Compose Power BI Data step to extract the actual contents, the full output which looks like below. Each Power BI output will contain 5-10 elements of 20 fields each. I'm trying to split this one set into two different arrays, one of fields 1-10, and another of fields 11-20.

     

    Then for each of those new arrays, I would like to add a new field at the end of each named "GUID" that contains the output of my guid() step.

     

    Spoiler (Highlight to read)
    {
        "Field 1""x",
        "Field 2""x - 2",
        "Field 3""OPEN",
        "Field 4""Brand",
        "Field 5""Address",
        "Field 6"0,
        "Field 7"2190,
        "Field 8"2445,
        "Field 9"-255,
        "Field 10"-0.104,
        "Field 11"0.209,
        "Field 12"0.212,
        "Field 13"-0.00,
        "Field 14"2022,
        [etc.]
        hoping for: "Field 20": guid output
      },
      [repeat 5-10 times with different values]
      }, 
    {    "Field 1": "x",    "Field 2": "x - 2",    "Field 3": "OPEN",    "Field 4": "Brand",    "Field 5": "Address",    "Field 6": 0,    "Field 7": 2190,    "Field 8": 2445,    "Field 9": -255,    "Field 10": -0.104,    "Field 11": 0.209,    "Field 12": 0.212,    "Field 13": -0.00,    "Field 14": 2022,    [etc.]    hoping for: "Field 20": guid output  },  [repeat 5-10 times with different values]  }, 

    Thanks for the help. I feel like this should be easier than I'm making it.

  • Verified answer
    SudeepGhatakNZ Profile Picture
    14,394 Most Valuable Professional on at

    This is what I mean. Since the field values are repeated for each item in the PARSE JSON output, if you reference any of the fields, it should generate a loop as shown below.

    I have simple pasted the following input in the compose action.

    [{
    "Field 1": "x",
    "Field 2": "x - 2",
    "Field 3": "OPEN",
    "Field 4": "Brand",
    "Field 5": "Address",
    "Field 6": 0,
    "Field 7": 2190,
    "Field 8": 2445,
    "Field 9": -255,
    "Field 10": -0.104,
    "Field 11": 0.209,
    "Field 12": 0.212,
    "Field 13": -0.00,
    "Field 14": 2022
    },{
    "Field 1": "x",
    "Field 2": "x - 2",
    "Field 3": "OPEN",
    "Field 4": "Brand",
    "Field 5": "Address",
    "Field 6": 0,
    "Field 7": 2190,
    "Field 8": 2445,
    "Field 9": -255,
    "Field 10": -0.104,
    "Field 11": 0.209,
    "Field 12": 0.212,
    "Field 13": -0.00,
    "Field 14": 2022
    }]

     

     

    SudeepGhatakNZ_0-1693444060155.png

     

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard