Skip to main content

Notifications

Community site session details

Community site session details

Session Id : H9RM/x0KZD+MdN43K4Er+k
Power Automate - Building Flows
Unanswered

How to extract values from a specific field and separate them by commas

Like (0) ShareShare
ReportReport
Posted on 21 Nov 2024 14:54:24 by 102
Hi Everyone!!

I have a 'Filter Array' action in Power Automate where I am extracting values from a specific field in the resulting array.
Below is an example of the filtered data I get back:
 
{
    "body": [
        {
            "ItemInternalId": "abc12345",
            "Contractor Name": "John Doe",
            "Assigned Enterprise ID": "john.doe",
            "Assignment ID": "12345",
            "Status": "Active",
            "Assignment Work Country": "Country A",
            "Project Name": "Project A",
            "Client Name": "Client A"
        },
        {
            "ItemInternalId": "xyz98765",
            "Contractor Name": "Jane Smith",
            "Assigned Enterprise ID": "jane.smith",
            "Assignment ID": "67890",
            "Status": "Active",
            "Assignment Work Country": "Country B",
            "Project Name": "Project B",
            "Client Name": "Client B"
        }
    ]
}
 
From this, I want to extract only the 'Assignment ID' values and return them as a string separated by commas, like this:

12345, 67890.

How can I achieve this in Power Automate? I'm looking for a solution that directly extracts these values and formats them as a comma-separated string.

Thank you for your help!
  • Chriddle Profile Picture
    7,708 Super User 2025 Season 1 on 25 Nov 2024 at 08:35:56
    How to extract values from a specific field and separate them by commas
    ...or just use an expression to replace the filter etc. (assuming you are only filtering for items whose contractor names are not empty):
    join(	
    	xpath(
    		xml(json(concat('{"Root":{"Item":', outputs('Compose'), '}}'))),
    		'//Item[Contractor_x0020_Name !=""]/Assignment_x0020_ID/text()'
    	),
    	', '
    )
     
  • FlowFalcon Profile Picture
    102 on 23 Nov 2024 at 19:04:25
    How to extract values from a specific field and separate them by commas

    Thank you, RaulLessa 

    I encountered an error in the select step due to the ".body" in step #2. The error was as follows:

    "The template language expression 'outputs('Compose').body' cannot be evaluated because property 'body' cannot be selected. Array elements can only be selected using an integer index."

    The solution was to remove ".body," so the expression ended up as: outputs('Compose').

  • RaulLessa Profile Picture
    2 on 21 Nov 2024 at 18:55:49
    How to extract values from a specific field and separate them by commas

    Hello!
    Here is the solution to extract only the 'Assignment ID' values and return them as a string separated by commas:

    Step 1: Add your JSON to a Compose action.

     

    Step 2: Add a Select action and populate the fields as follows:

    • From: outputs('Compose').body
    • Map: item()?['Assignment ID']
     
    Step 3: Add a Join action. In the From field, add the output of the Select action: body('Select').
    And Join with field add ", "
     
    Final Result:
    Hope this helps!

    If I helped you solve your problem—please mark my post as a solution.
    Consider giving me a 👍 if you liked my response!
     
     
     

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Automate - Building Flows

#1
stampcoin Profile Picture

stampcoin 73

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 66 Super User 2025 Season 1

#3
David_MA Profile Picture

David_MA 48 Super User 2025 Season 1

Overall leaderboard