cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
nouptime
Frequent Visitor

Returning union expression output as comma-separated values instead of JSON array

I have an Excel file with a column that contains duplicate values. The idea here is to capture rows from a specific column, parse them to JSON then select the itemid value, followed up a union operation:

 

union(body('Select'),body('Select'))

 

Then I used a join expression on the output of the union and assigned it to a variable:

 

join(outputs('Remove_duplicate_details'),',')

 

Finally at the end there is an Update item connector to push this to SharePoint, where I get the following output in a multiple lines of text column. Is there a way to get this output in a more readable format such as 26109, 23913...etc ?

nouptime_0-1625844073247.png

 

Below is a snippet of the specific connectors used in my flow:

FlowUnionJson.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
PrasadAthalye
Community Champion
Community Champion

  • Declare an Array variable and use varItemidString to set the array elements.
  • Declare a string variable to generate output.
  • Run a loop on it and use parse json to parse individual object.

PrasadAthalye_1-1625861515972.png

 

  • Use Apppend to string variable to generate output.
  • Finally you can trim last comma using substring wherever you are using string variable...

 

PrasadAthalye_0-1625861438158.png

 

 

 

Please Like and Mark this as Answer if it resolves your Issue.

Power Automate Community

View solution in original post

3 REPLIES 3
PrasadAthalye
Community Champion
Community Champion

  • Declare an Array variable and use varItemidString to set the array elements.
  • Declare a string variable to generate output.
  • Run a loop on it and use parse json to parse individual object.

PrasadAthalye_1-1625861515972.png

 

  • Use Apppend to string variable to generate output.
  • Finally you can trim last comma using substring wherever you are using string variable...

 

PrasadAthalye_0-1625861438158.png

 

 

 

Please Like and Mark this as Answer if it resolves your Issue.

Power Automate Community

This is excellent, thank you!

 

Just to add, I used the union output in the Apply to each function. Then I followed the subsequent steps and added a substring expression to get the expected output.

Anonymous
Not applicable

I know this is an old topic, but you can do what you want fairly easily without the Apply to each loop.  This is something I have done with email lists. 

Easiest way is to change your Select statement to select only the numbers without the "Itemid" key.  

 

Change the Select to 'text' mode instead of key-value mode using the option on the right.

rickmussi_0-1641324693356.png

This will map only the id numbers in an array.  Use the join to get them in a comma separated list.

The other option would be to use the Replace expression to remove the undesired characters from your string before sending to SharePoint.  But I prefer the select using text mode. 

 

 

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (4,858)