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.

rickmussi
Frequent Visitor

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
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (3,606)