web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Splitting array invalid
Power Automate
Unanswered

Splitting array invalid

(0) ShareShare
ReportReport
Posted on by 76

I have apply to each loop which creates filenames, i used append to variable array to create a long string of all filenames that got created "name1.zip,name2.zip,name3.zip,". Because i want to use these filenames outside my for each loop to compare to a list later on in my steps. i added a comma to the end of each filename ","  to use as seperator, so i can split them later

 

i want to split this to:

name1.zip

name2.zip

name3.zip

 

Its saying my expression is invalid and i don't understand why. i used:  split(variables('Array of file names'),",")

Kryptic_0-1600253796328.png

 

Categories:
I have the same question (0)
  • efialttes Profile Picture
    14,756 on at
    Re: Splitting array invalid

    Hi

    It seems you are using double quotes to wrap the comma inside your split() based WDL expression. If so, try with single quotes instead

    split(variables('Array of file names'),',')

    Hope this helps

  • Kryptic Profile Picture
    76 on at
    Re: Splitting array invalid

    Thanks, that worked. I ran into another problem:

    You can see the filename i create, then theyre added thogether into an array, i need to split these but that can only do to a variable of type string...

    Kryptic_0-1600254583545.png

     

     

  • CFernandes Profile Picture
    8,402 Most Valuable Professional on at
    Re: Splitting array invalid

    @Kryptic  

     

    Can you please try the Function below - I have decorated the variable to be of type string()

     

    split(string(outputs('Compose')),',')

     

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

  • Kryptic Profile Picture
    76 on at
    Re: Splitting array invalid

    Thanks that got me one step further,  i split it at "/" now using: split(string(variables('Array of file names')),'/')

     

    I need 2 more things to solve this puzzle

     

    1. When i look at the output i see 3 outsputs, why is that? i just need:

     

    file1.zip

    file2.zip

     

    Kryptic_0-1600260728775.png

     

     

    2. For every composed string, (which represents a filename) i want to preform an action.

    I want to compare that name to a list of files present in a FTP folder, if the name matches with one of the filenames in the folder, nothing should happen.

     

    If theres no match, it means a file is missing and i want a email notification. that that filename is not present in my FTP folder.

     

    The flow below doesn't work but i constructed it to kinda show the goal i'm aiming towards:

    Kryptic_1-1600261678289.png

     

     

     

     

  • efialttes Profile Picture
    14,756 on at
    Re: Splitting array invalid

    Hi again

    In my opinion, Problem#1 is due to the fact you always have a comma at the end of your string, I mean the one you convert into an array by means of split().

    So when performing split(), you always get an extra empty element at the end of your array.

    IN your first scfeenshot, you have an 'Append to string' inside an 'Apply to each', right?

    My suggestion is to remove 'Append to string', move 'Append to array' inside the 'Apply to each', and assign as its input the expression you are currently using on 'Append to string'. This way you create an array, each element a FileName, no commas, no need for split().

    Hope this makes sense

  • CFernandes Profile Picture
    8,402 Most Valuable Professional on at
    Re: Splitting array invalid

    @Kryptic We can try to use the replace function and replace all the special characters from the string (",[) with an empty string '' but that is going will not end up in a good solution. 

     

    I agree with @efialttes  latest comments and I think that will indeed create a much easier and reliable solution.

     

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

  • Kryptic Profile Picture
    76 on at
    Re: Splitting array invalid

    Thank you, that is alot more simple and got me the string i want for each loop. Now the last step to complete this flow:

     

    For every file created i now have the name, I then retrieve a list of all files in my output folder. 

    For every file created I need to compare the created file name to every file in the retrieved files list (after a minute)

     

    If the created file name is also in the list of retrieved file names, everything is fine.

    If the created file name is not in the list of retrieved file names, i need a email notification one is missing. 

     

    Basically:

    use createdfilename1.zip and create some kind of loop

     

    compare createdfilename1.zip to retrievedfilename1.zip, if match

    goto next (with createdfilename2.zip)

    else

    compare createdfilename1.zip to retrievedfilename2.zip, if match

    goto next (with createdfilename2.zip)

    else

    compare createdfilename1.zip to retrievedfilename3.zip, if match

    goto next (with createdfilename2.zip)

     

    if no match found -> email notification and goto next (with createdfilename2.zip)

     

    run that untill all createdfilenames are checked

     

    Knipsel.PNG

     

     

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

#2
Tomac Profile Picture

Tomac 456 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard