Skip to main content

Notifications

Community site session details

Community site session details

Session Id : ki4ukr/PaBDuKgtSk4Anu4
Power Automate - Building Flows
Unanswered

Choices, xpath, & [Brackets]

Like (0) ShareShare
ReportReport
Posted on 24 Mar 2020 03:43:59 by Microsoft Employee

Hi all, I'm using xpath(xml(json(concat('{"root":{"choices":', item()?['MyValue'] , '}}'))), '/root/choices/Value/text()') to return an array from my Sharepoint list for each Choices column type and adding it to an HTML table.

When the values appear for each of the Choices columns, they appear in the HTML table as ["Value1","Value2"] but I want them to appear as Value1, Value2.

I've been trying to use replace unsuccessfully, so far, to strip out the brackets and quotes around each of the values so only the value itself is returned. ?

Thanks in advance!

  • MrCle4n Profile Picture
    37 on 01 Apr 2023 at 08:04:01
    Re: Choices, xpath, & [Brackets]

    @arghhh 


    Is there a way for me to give you a virtual hug, kiss, and high five?

     

    I have been wracking my brain for about 5 days trying to get this to work, your simple "just add join to your xpath" just made me almost cry from happiness.

     

    Thank you so much!!!!!

  • arghhh Profile Picture
    8 on 15 Feb 2022 at 21:39:12
    Re: Choices, xpath, & [Brackets]

    @russrimm @Exon02 

    Add join to your xpath to set your delimiter at the end of the expression.

     

    join(xpath(xml(json(concat('{"root":{"choices":', item()?['MyValue'] , '}}'))), '/root/choices/Value/text()')', ')

     

    Or for example pulling a DisplayName out of a people picker.

     

    join(xpath(xml(json(concat('{"body":{"value":', item()?['value'], '}}'))), '/body/value/DisplayName/text()'), ', ')
  • russrimm Profile Picture
    Microsoft Employee on 29 Nov 2021 at 14:47:00
    Re: Choices, xpath, & [Brackets]

    Hi @Exon02 I ended up changing the column type to text and using comma delimited values with Split.  I've learned to avoid using Choice column types more.

  • Exon02 Profile Picture
    2 on 26 Nov 2021 at 08:00:14
    Re: Choices, xpath, & [Brackets]

    @russrimm 

     

    i'm having the same issue how did you resolve it? Please share.

    Thanks in advance!

  • v-bacao-msft Profile Picture
    on 06 Apr 2020 at 06:48:35
    Re: Choices, xpath, & [Brackets]

     

    Hi @russrimm ,

     

    I remember that I have responded to this question and provided some suggestions in the email message you sent me. Please check it.

     

    Best Regards,

  • ChristianAbata Profile Picture
    8,947 Most Valuable Professional on 05 Apr 2020 at 21:10:24
    Re: Choices, xpath, & [Brackets]

    @russrimm  could you share an screanshot to understand better?

  • russrimm Profile Picture
    Microsoft Employee on 05 Apr 2020 at 20:34:25
    Re: Choices, xpath, & [Brackets]

    If I try doing an initialize variable of the Array type, as soon as I add my "Choices" column, it automatically adds an Apply to Each step and then tells me that I can't have an initialize array as the first step in an Apply to Each.  I just want all the choices they selected (the choices columns allow multiple selection) to show in the CSV and HTML tables without the ["   "] around them, otherwise it's working OK as it is.  It just gets the items and adds them all to a csv and html, but the Choices columns are always adding the [" "].

  • v-bacao-msft Profile Picture
    on 24 Mar 2020 at 05:19:48
    Re: Choices, xpath, & [Brackets]

     

    Hi @russrimm ,

     

    Please try to use Join to remove brackets and quotes, since that it is an array.

    192.PNG193.PNG

    Hope this helps.

     

    Best Regards,

  • DeepakS Profile Picture
    2,301 Most Valuable Professional on 24 Mar 2020 at 04:53:50
    Re: Choices, xpath, & [Brackets]

    Hi @russrimm 

     

    Can you share a screen capture of the flow so i can understand /help you better.

     

    -----------------------------------------------------------------------------------------
    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.

  • russrimm Profile Picture
    Microsoft Employee on 24 Mar 2020 at 04:45:56
    Re: Choices, xpath, & [Brackets]

    Thanks Deepak, I can get them into an array, I guess what i'm not sure if is once I get them into the array how to get them into my html table without the [""] around the values.  I can't initialize an array variable in an Apply to Each, so it seems like ultimately I need to somehow initialize the array and join the values with a comma and then insert that into each row in my html table just to get rid of the [""].  When I try to initiailze the array it automatically adds an apply to each and then I get an error letting me know I can't initialize an array in an apply to each.  My first step is a "Get sharepoint items" and then 3 of the columns are a "Choices" type and may have more than one value.  Those are the ones i'm trying to strip the brackets and quotes from when they're added to my html table.

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
Michael E. Gernaey Profile Picture

Michael E. Gernaey 66 Super User 2025 Season 1

#2
stampcoin Profile Picture

stampcoin 65

#3
rzaneti Profile Picture

rzaneti 39 Super User 2025 Season 1

Overall leaderboard