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 / How to joint multiple ...
Power Automate
Unanswered

How to joint multiple string with comma in Apply to each loop?

(1) ShareShare
ReportReport
Posted on by 12

I have a multiple choice field in SP list.

When I get one row in Automate, I need the multiple choice field show like as 
"AAAA,BBBB,CCCC" as a string
Using Append to String to add comma, but How to make this correctly in apply to each? 

 

1.  If I can set condition in apply to each, to know this is the last one , I can stop append the last comma.

Or, 2. After loop append comma for all item, then remove the first comma head of AAAA.

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

    Hi @EricXIII 

     

    In my understanding, when you use ’Get items’ in sharepoint, you want those multiple choices (for example: a multiple choices value for a row contains 3 choices, which are ‘AAAA’,’BBBB’,’CCCC’) in every row to show as ‘AAAA,BBBB,CCCC…’.

     

    Yes, you will need to create an array variable to store those multiple choices values in apply to each.

     

    The following flow is for your reference:

    2.19-9.PNG

     

    The detailed steps for ‘initialize variable’:

    2.19-10.PNG

    The array variable ‘multiple choice’ is used to store each value of multiple choices for each row (in ‘Apply to each’).

    The array variable ‘multiple choices array’ is used to store all multiple choices for each row (in ‘Apply to each’).

     

    The detailed steps for ‘Apply to each 2’:

    2.19-11.PNG

    ‘Value’ in ‘Append to array variable 2’:

    {

      "array": @{variables('multiple choice')}

    }

     

    The detailed steps for all the ‘compose’ and ‘set variable’:

     

    It’s quite important to know the difference between ‘Append to array variable’ and ‘set variable’:

    The 'set variable' action will reset the variable, which erases all the content formerly exist in the variable.

    The 'append to array variable' action will add new content to the variable and retain the content formerly exist.

     

    2.19-12.PNG

    The functions used above:

    last(variables('multiple choices array'))

    outputs('Compose_2')['array']

    join(outputs('Compose_3'),',')

    null

     

    For more info about the function last(), outputs(), join():

    Reference guide for functions in expressions - Azure Logic Apps | Microsoft Docs

    Reference guide for functions in expressions - Azure Logic Apps | Microsoft Docs

    Reference guide for functions in expressions - Azure Logic Apps | Microsoft Docs

     

    Best Regards,
    Community Support Team _ Kira Xie
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • GabrielFLima Profile Picture
    12 on at

    I know it's already been answered, but I found a solution for a problem similar like this that's quite easier to implement (although I'm not sure if it's more demanding computationally).

     

    First, I set a variable as the first element of the original array.

     

    GabrielFLima_1-1678801672631.png

     

     

    Then, I created an array of Indexes, ranging from 1 to the index of the last item in the original array, which is "Participantes" (that's why I subtracted 1 from the length in the "IndiceNomes" action).

     

    Now looping through those indexes, I used an Append to String Variable action to append a concatenation to the variable, being basically: ", ParticipantName" (in your case there would be no space after the comma).

     

    GabrielFLima_0-1678801498058.png

     

    This way, you don't even have to eliminate the first comma that would appear, and you're good to go!

     

    Hope it's easy to understand, specially since I demonstrated it using my own variables and stuff

  • Suggested answer
    Golly Profile Picture
    127 on at
    There is an even simpler way to do this. I'll use my data in the example.  The 'Business Group' is a multiselect field in a SharePoint List.
     
    Use Select to pull the field you want from the original array:
    and a compose statement to join the array elements with a comma:
    Just 2 statements and no looping!

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 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard