Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
Answered

How to create an array of integers from SPLIT

(0) ShareShare
ReportReport
Posted on by 63

Seeking assistance on converting the output of SPLIT from a substring into an array of integers

 

The requirement is to create an array of integers like [7,53,57,58] from data that is formatted "7,53,57,58"
Using SPLIT I can create a substring "7","53","57","58" and then pass that to ARRAY to give ["7","53","57","58"] however this is not acceptable because the value must be int(). What is the best way to convert the values from strings to integers inside the array?

 

Declare a empty array and loop through each member and convert to an int()? Can anyone give advice on this?

 

SPOD_0-1623918677124.png

 

 

 

  • louis_J Profile Picture
    12 on at
    Re: How to create an array of integers from SPLIT

    Is there no way to work without loops ? Loops are so time consuming.. the whole idea of the split and array is to not have to use a loop

  • Verified answer
    SPOD Profile Picture
    63 on at
    Re: How to create an array of integers from SPLIT

    Hi @v-bofeng-msft 

    Brilliant Many thanks your solution is spot on.

    Here is my understanding of how it works for anyone else who comes this way

    1. data comes from excel ‘for a selected row’ and the data is formatted “1,2,3,4”
    2. And initialise variable creates an array that is empty, do not enter anything in the value
    3. the apply to each operation accepts an array as a source and then you can add an action in other words it kind of does two things in one
      1. split (<from the selected row in excel>,’,’) converts the data from excel into an array separated by commas.
      2. append to array variable, each item in the array and converts it to a integer and then appends this to the initially created array in Step 2.  int(items('Apply_to_each'))
    4. The final step just visualises the completed flow, the output being an array of integers separated by commas)

    Many thanks for your assistance Bof.2021-06-18_18-26-48.png

  • Verified answer
    v-bofeng-msft Profile Picture
    on at
    Re: How to create an array of integers from SPLIT

    Hi @SPOD :

    Yes.You need to declare an empty array variable first, then iterate over the results of the split, and finally fill this variable with the int() function.

    The solution I provided should fully meet your requirements.

    vbofengmsft_0-1623980774323.png

    Best Regard,

    Bof

     

  • SPOD Profile Picture
    63 on at
    Re: How to create an array of integers from SPLIT

    Hi @v-bofeng-msft 

     

    The problem with that solution is initial compose input in your example is starting from an array of integers.  My data is "7","53","57","58", i'm looking for a method to convert the data into an array of integers because the api I'm working with will not accept the values in quotes.  I'm thinking the idea of declaring an empty array and then looping through each member in ["7","53","57","58"] and using INT() to populate the (empty ) initialised array. Will that work or is there a better way? 

     

  • v-bofeng-msft Profile Picture
    on at
    Re: How to create an array of integers from SPLIT

    Hi @SPOD :

    I've made a test for your reference:

    vbofengmsft_0-1623920262490.png

    The Result:

    vbofengmsft_1-1623920292396.png

    Best Regards,

    Bof

     

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,524 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,906 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow