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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Flow to concatenate al...
Power Automate
Answered

Flow to concatenate all SP column values in a single row.

(0) ShareShare
ReportReport
Posted on by 31

Got a simple yet tricky flow I'm stuck with.

Let's say I got the following SP list with 3 columns (all of type SingleLineOfText). 

 

ColorDayPet
BlackMondayDog
RedSundayCat
YellowSaturdayParrot

 

Output i'm trying to get is all the values of each individual column separated by "/".

So for above example I want to do a "Get items" from SharePoint and then add a row in an existing excel file which should look like this.

ColorDayPet
Black/Red/YellowMonday/Sunday/SaturdayDog/Cat/Parrot

 

Only way I figured out would be to initialize a string for every single column (varColor, varDay, varPet) and then do 3 "Append to string" actions in a loop to append the next value to all variables and just add the variable in the new excel row. Problem with that approach is that in reality i'm having many lists with way more columns so i'm trying to find an expression that does the trick and avoid ending up with 200 initialize/append variable actions in a single flow.

Categories:
I have the same question (0)
  • v-dezhili-msft Profile Picture
    Microsoft Employee on at

    Hi @MuFeR ,

    I have a test for your reference.

     

    vdezhilimsft_0-1669714599999.png

     

    vdezhilimsft_1-1669714600001.png

     

    vdezhilimsft_2-1669714600002.png

     

    vdezhilimsft_3-1669714600003.png

     

    vdezhilimsft_4-1669714600005.png

     

    vdezhilimsft_5-1669714600006.png

     

    Best Regards,

    Dezhi

  • Verified answer
    grantjenkins Profile Picture
    11,063 Moderator on at

    This requirement aligns to using XPath perfectly.

     

    My list used in this example:

    grantjenkins_1-1669721897921.png

     

    And my Excel Table:

    grantjenkins_2-1669721946597.png

     

    See my full flow below. I'll go into each of the actions.

    grantjenkins_0-1669721844262.png

     

    Get items retrieves all the items from my SharePoint List.

    grantjenkins_3-1669721993765.png

     

    XML is a Compose action that converts the body of Get items to XML so that we can use XPath in the next step. It also adds a root element to ensure its valid XML. The expression used here is:

    xml(json(concat('{"root": ', outputs('Get_items')?['body'], '}')))

    grantjenkins_4-1669722096272.png

     

    And finally, we have our Add a row into a table which takes in the following expressions for Color, Day, and Pet respectively. This extracts out each of the values and joins them with a /

    join(xpath(outputs('XML'), '//root/value/Color/text()'), '/')
    
    join(xpath(outputs('XML'), '//root/value/Day/text()'), '/')
    
    join(xpath(outputs('XML'), '//root/value/Pet/text()'), '/')

    grantjenkins_6-1669722269188.png

     

    And the output after the flow completes, we have the values joined, separated by /

    grantjenkins_5-1669722231326.png

     

  • MuFeR Profile Picture
    31 on at

    Does the xml expression only work with the Get_items action or could it also be modified to work with Filter Array?

    I tried to use
    xml(json(concat('{"root": ', body('Filter_array'), '}')))

    but i get the error "Unable to process template language expressions in action 'XML' inputs at line '0' and column '0': 'The template language function 'xml' parameter is not valid. The provided value cannot be converted to XML: 'This document already has a 'DocumentElement' node.'."

  • Verified answer
    grantjenkins Profile Picture
    11,063 Moderator on at

    You'd just need to wrap the array into a property as so:

     

    xml(json(concat('{"root": { values:', body('Filter_array'), '}}')))
  • MuFeR Profile Picture
    31 on at

    Thanks this worked perfectly!
    I also had to modify the next part from:
    '//root/value/Color/text()' to '//root/values/Color/text()'  

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard