cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

split string and apply for each

Ok, I've read a few articles and submissions on this form and elsewhere in Azure logic apps, but I'm not getting it.

Very simply, I want to pass Flow a string with elements separated by a semicolon and then run a foreach on each of the items from the split.

 

 

As I've said, there are a couple of articles, but I just can't wrap my head around them.  People have said "oh yes, the JSON needs to be encapsulated in double quotes" - but where or what or how, I can't seem to fathom.

 

There are a couple of holes in my knowledge;

 

The format of the thing I'm passing to Flow from PowerApps - can it just be a variable or must it include quotes or what?

 

I've tried;

 

'FLOWNAME'.Run(ContextVariableContainingString)

I've also tried just 

 

'FLOWNAME'.Run("bob;sue;joe")

and 

 

 

'FLOWNAME'.Run("[\"bob;sue;joe\"]")

but I clearly have no clue what I'm doing and nothing changes the outcome.
So I also can't figure out what the flow syntax is...

 

 

{@split(powerapps_input, ';')}

or

@split(powerapps_input, ';')

or

split(powerapps_input, ';')

I've tried reading the language reference, it just says

split('a;b;c',';')


The compose piece works, but if I try plug the output into a foreach I get told it's a string and not an array...so I can theorise that I need to apply some sort of JSON conversion on the string or something, but I've no clue how.

 

Whether I'm on the right track or not, I'm tired of trying - can someone please give me a working example from scratch of sending a simple variable from powerapps, splitting it, and then doing a foreach on each of the split items?

 

here's hoping,

 

R

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Re: split string and apply for each

Hi @Anonymous,

 

Try the following under Microsoft Flow:

30.PNG

The format within PowerApps should be string, we could take use of the TextInput.Text, or just the string with double quotes:

SplitString.Run(TextInput1.Text)

SplitString.Run("Tom;Ammy;Mike;Sam;Bob")

Split function under Microsoft Flow would create an Array in Microsoft Flow, if we would like to reference the item, we use the item() function.

31.PNG

Regards,

Michael

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

View solution in original post

10 REPLIES 10
Community Support
Community Support

Re: split string and apply for each

Hi @Anonymous,

 

Try the following under Microsoft Flow:

30.PNG

The format within PowerApps should be string, we could take use of the TextInput.Text, or just the string with double quotes:

SplitString.Run(TextInput1.Text)

SplitString.Run("Tom;Ammy;Mike;Sam;Bob")

Split function under Microsoft Flow would create an Array in Microsoft Flow, if we would like to reference the item, we use the item() function.

31.PNG

Regards,

Michael

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

View solution in original post

jlazerus
Frequent Visitor

Re: split string and apply for each

Would this work for an input with multiple rows of comma separated values? I'm trying to figure out how to turn csv into json (array)?

amandalee Advocate II
Advocate II

Re: split string and apply for each

Hi there, did you end up finding the answer to your question? I am looking to turn comma separated values into an array in flow as well but haven't been able to find much documentation on it.

Highlighted
kbirstein1 Advocate III
Advocate III

Re: split string and apply for each

I'm having the same problem. Something so simple should be documented CLEARLY in the Flow documentation. 

 

PROBLEM STATEMENT:

 

Comma deliminted stirng, i.e. "Bob","Ted","Carol"

 

How to turn into a FLOW ARRAY?

kbirstein1 Advocate III
Advocate III

Re: split string and apply for each

Or in my case this string:

 

["0002\n0004\n0009\n0013\n0014\n0015\n0016\n0018\n"]

NeilMcC
Regular Visitor

Re: split string and apply for each

I'm chipping away at the same issue. Essentially, I want to load a csv file into a SPO list.

Format will be something like this:

"id","name","description","<etc>"

and multiple values for each field listed beneath.

I've managed to use the split() function to break this by carriage return, put it in an array variable and I can have my Flow iterate over the 49 records. However, I can't use any of the field values within each line. It looks like what I've got so far is an array of arrays.

Can I convert to json so that I can use each field from each record to map to SPO list items?

Can I use the csv table action?

Should I just be carving up the text file differently to start with?

NeilMcCafferty
Regular Visitor

Re: split string and apply for each

Me too!

Liesl
New Member

Re: split string and apply for each

The solution in this post allows you to split a string into an array

 

https://powerusers.microsoft.com/t5/Building-Flows/Splitting-comma-separated-string-and-returning-a-...

 

Line 1: first(split(body('Parse_JSON')?['AddressLines'],'\n'))

Line 2: first(skip(split(body('Parse_JSON')?['AddressLines'],'\n'),1))
Line 3: first(skip(split(body('Parse_JSON')?['AddressLines'],'\n'),2))
v-shsang
Frequent Visitor

Re: split string and apply for each

hi NeilmcC,

 

Were you able to resolve the issue? I am facing the same problem and wa sthinking if you have a solution now.

 

Thank you,

Shipra

jlazerus
Frequent Visitor

Re: split string and apply for each

I did find a solution to my problem of converting CSV to json. However it involved creating an Azure Function. 

 

https://arkeytek.com/azure/azure-functions-logic-app-csv-to-json

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Automate Community!

firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Users online (7,629)