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 / In a Power Automate ar...
Power Automate
Answered

In a Power Automate array Group By on 1 column and concatenate text in other column

(2) ShareShare
ReportReport
Posted on by 42
I have below Array in Power Automate: 
 
{
    "body": {
        "name": "vAnswersArray",
        "type": "Array",
        "value": [
            {
                "Index": 0,
                "Title": "AC-01",
                "Answer": "test ac01 a"
            },
            {
                "Index": 1,
                "Title": "AC-02",
                "Answer": "test ac02 a"
            },
            {
                "Index": 2,
                "Title": "AC-03",
                "Answer": "test ac03 a"
            },
            {
                "Index": 3,
                "Title": "AC-04",
                "Answer": "test ac04 a"
            },
            {
                "Index": 4,
                "Title": "AC-01",
                "Answer": "test ac01 b"
            },
            {
                "Index": 5,
                "Title": "AC-03",
                "Answer": "test ac03 b"
            }
        ]
    }
}
 
My question is, I want to Group by on Title column and concatenate text in Answer column, So how to get below output:
 
"value": [
            {
                "Index": 0,
                "Title": "AC-01",
                "Answer": "test ac01 a \n test ac01 b"
            },
            {
                "Index": 1,
                "Title": "AC-02",
                "Answer": "test ac02 a"
            },
            {
                "Index": 2,
                "Title": "AC-03",
                "Answer": "test ac03 a \n test ac03 b"
            },
            {
                "Index": 3,
                "Title": "AC-04",
                "Answer": "test ac04 a"
            }
        ]
 
Index column need not come in output. I appreciate all answers, Thanks.
Categories:
I have the same question (0)
  • Verified answer
    Chriddle Profile Picture
    8,708 Super User 2026 Season 1 on at
    With your object in a Compose, it's just one Select using xPath:
     
    From:
    union(
    	xpath(
    		xml(
    			addProperty(
    				json('{}'),
    				'Root',
    				addProperty(
    					json('{}'),
    					'Item',
    					outputs('Compose')['body/value']
    				)
    			)
    		),
    		'//Item/Title/text()'
    	),
    	json('[]')
    )
    Map Title:
    item()
    Map Answer:
    join(
    	xpath(
    		xml(
    			addProperty(
    				json('{}'),
    				'Root',
    				addProperty(
    					json('{}'),
    					'Item',
    					outputs('Compose')['body/value']
    				)
    			)
    		),
    		concat('//Item[Title = "', item(), '"]/Answer/text()')
    	),
    	decodeUriComponent('%0A')
    )
     
    Add the indexes with a second select and the help of the range function.
  • Verified answer
    Kalathiya Profile Picture
    2,456 Super User 2026 Season 1 on at
    Hello @gavasthi1,
     
    Yes, this can be achieved by grouping by the Title field and concatenating the Answer field.
     
    Approach:
    #1. Declare Output Array Variable
    #1. Get unique Titles using union()
    #2. Loop through each Title
    #3. Filter original array for that Title
    #4. Concatenate Answers
    #5. Build final grouped array
     
    Steps: 
    Declare Output Array Variable
     
     
    1. Add Select Action: Select only title column from ArrayOutput for Group by
    Expression for Map Property: 
    item()?['Title']
     
     
    2. Add Compose: Store unique value of Title
    Expression
    union(body('Select_|_Title_Column'),body('Select_|_Title_Column'))
    Note: In above expression, //My selection name is "Select_|_Title_Column" so i have added - Replace this with your select action name.
     
     
    3. Add Apply to each:  - Output - Add output of Group by Title compose

    Below all action you need to add in Apply to each action: 
    4. Then inside the apply to each add filter array action:
     
    5. Add Select Action: 
    From: Select Filter Array Action output body
    Map: write Expression
    item()?['Title']
     
    6. Add Join Action
    From :Select Action output body
    Join: 
    decodeUriComponent('%0A')
    
     
     
     
    7. Add Action called Append to array select your output array variable
     
     
    Final Apply to each action:
     
    Output:
     
     
    ---------------------------------------------------------------------------------
     
    📩 Need more help? Mention @Kalathiya anytime!
    ✔️ Don’t forget to Accept as Solution if this guidance worked for you.
    💛 Your Like motivates me to keep helping!
  • gavasthi1 Profile Picture
    42 on at
    Thanks , your solution worked for me.
  • gavasthi1 Profile Picture
    42 on at
    Thanks @Kalathiya, your solution worked for me.

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 377

#2
11manish Profile Picture

11manish 279

#3
David_MA Profile Picture

David_MA 234 Super User 2026 Season 1

Last 30 days Overall leaderboard