cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Morke
Helper II
Helper II

How do you split items inside an array?

Hi

I have a single string which I need to split two times.

I have no issues splitting it the first time like this way:

 

String: "0;1;2; | a;b;c; | A;B;C; |"


Action: Initiate Variable 

Name: varArray

Type: Array

 

Action: Set Variable

Input: varArray

Value: split('string','|')

 

Output:

[
  [
    "0;4;Premium SSD;",
    "1;4;Premium SSD;",
    "2;4;Premium SSD;",
    "3;4;Premium SSD;",
    ""
  ]
]
 
 
 
Now, how do I further split each item of the array, producing an array of arrays?
 
 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-bacao-msft
Community Support
Community Support

 

Hi @Morke ,

 

Please check the following configuration and see if it helps:

163.PNG

We could use items('Apply_to_each') to get the item of the array and continue to use split() function to handle it.

Hope this helps.

 

Best Regards,

Community Support Team _ Barry
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

4 REPLIES 4
v-bacao-msft
Community Support
Community Support

 

Hi @Morke ,

 

Please check the following configuration and see if it helps:

163.PNG

We could use items('Apply_to_each') to get the item of the array and continue to use split() function to handle it.

Hope this helps.

 

Best Regards,

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

Thank you for the help. This works.

I have a doubt, what's the reference to "items()"? I want to understand how it works.

Also:
How can I use all the resulting split strings? I mean how do I use them as objects further down in the flow after this split? What's the reference to them?

 

Hi @Morke ,

 

The Split() function will return an array. We generally use Apply to each to traverse the elements in the array, and the items() function is used to get the elements of each traversal.

 

If the element is an object, then we can get the property value through items()[‘PropertyName’].

 

You can use Apply to each to get each element and apply it to other actions, but the action must also be configured in Apply to each.

 

In addition, since the return value is an array, we can use index to get the value of each element. Like: You can get the value of the first element in the array through split ('string', '|') [0].

 

For more details, please refer to WDL function:

 

By doing more tests, we can easily master Data operations in Power Automate.

 

Best Regards,

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

Nice and simple 👍

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

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

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Users online (3,557)