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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / join consecutive key/v...
Power Automate
Answered

join consecutive key/value pairs in an array.

(0) ShareShare
ReportReport
Posted on by 8

Hi,

I have an array of key/value pairs that looks like this:

[
{
"ID": "https://knowledgebase.com/link_to_article_1"
},
{
"Title": "Title of Article 1"
},
{
"ID": "https://knowledgebase.com/link_to_article_2"
},
{

"Title": "Title of Article 2"

}
]

How can I combine consecutive array elements so that it looks like this instead?

[
{
"ID": "https://knowledgebase.com/link_to_article_1",
"Title": "Title of Article 1"
},
{
"ID": "https://knowledgebase.com/link_to_article_2",
"Title": "Title of Article 2"
}
]

Categories:
I have the same question (0)
  • MJain Profile Picture
    2,450 on at

    Hi @rleonen ,

     

    You need to use Select action to get the required data. This action maps the data from input to output.

     

    in your case all you need to do map like this 

     

    ID --> item()?['ID']

    Title-->item()?['Title']

     

    ManishJain_0-1626815565211.png

     

     

    Thanks

     

     

     

  • rleonen Profile Picture
    8 on at

    That suggestion is close but I don't get the consecutive rows combined into a single element. The output after using the 'Select' action now looks like below. Is there a way to combine the consecutive rows into a single element?

    [
      {
        "Title"null
      },
      {
        "ID"null,
        "Title""Document Needs to Have World Read Permission"
      },
      {
        "Title"null
      },
      {
        "ID"null,
        "Title""NAO How to create Jira Change Requests for L&D IT North America team"
      }
    ]
  • Paulie78 Profile Picture
    8,424 Moderator on at

    Take a look at this screenshot (I also included run history on right hand side). It does what you want. If you have any trouble following, I will explain in more detail:

    https://ibb.co/v42ZHFZ

     

    Blog: tachytelic.net

    YouTube: https://www.youtube.com/c/PaulieM/videos

    If I answered your question, please accept it as a solution 😘

  • Verified answer
    DamoBird365 Profile Picture
    8,942 Microsoft Employee on at

    Hi @rleonen 

     

    A lot simpler way of doing it, is just by using a select like @ManishJain has suggested and using some of @Paulie78 length logic.  It can be done in one simple action as follows:

     

    DamoBird365_0-1626850217288.png

    Your from is 

    range(0,div(length(outputs('Compose')),2))
    which is a range from 0 to the length of the array divided by 2
     
    Your ID value is:
    outputs('Compose')[mul(item(),2)]?['Id']
    which is the range value multiplied by 2, i.e. 0,2,4,6,8 .....
     
    Your Title ID is:
     outputs('Compose')[add(mul(item(),2),1)]?['TItle']
    which is the same as above +1, i.e. 1,3,5,7,9 ....
     
    The flow runs as follows:
    DamoBird365_1-1626850360834.png

    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 😉

  • rleonen Profile Picture
    8 on at

    Thanks Damien - solution works perfectly!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 997

#2
Valantis Profile Picture

Valantis 810

#3
Haque Profile Picture

Haque 642

Last 30 days Overall leaderboard