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 / Help with comparing st...
Power Automate
Unanswered

Help with comparing strings with array e.g string a contains in array [a;b;c]

(1) ShareShare
ReportReport
Posted on by 172

Hi All
I have field in sharepoint list that i store these values its not a multi choice field but a single line of text
The values look like this a;b;c;d

I have split the values below

 

 

split(variables('var_splitCatEquip'),';')

 

 

 and the output is this

 

 

["a","b","c","d","]

 

 

and also adding it to an array

naijacoder_0-1617256206083.png

 


For now i would like to compare using a condition

naijacoder_1-1617256298399.png

The top string gets the first index of the array (Also how can i dynamically loop through each values here like a for each in JavaScript?)

 

naijacoder_2-1617256555563.png

The above is just the values of all the arrays e.g [a;b;c;d]
But when i test the flow it is always returning false...

Not sure why?I'm probably missing something

Thanks in advance

 

Categories:
I have the same question (0)
  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at

    Hi @naijacoder 

     

    You would want to drop your array into an apply to each action and then you can use each value in your condition.

     

    When I am debugging, I often rely on the compose action.  It is easily added/removed and will quickly identify the data I am playing with.  So in your case, I think you have your condition the wrong way around.  You've got "a contains abcd" whereas you want "abcd contains a".

     

    I've also done a blog post on comparing arrays which you might find useful.

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    Cheers,
    Damien


    P.S. take a look at my new blog here

     

     

  • naijacoder Profile Picture
    172 on at

    Thanks DamoBird365.
    You are absolutely correct i have had used it the opposite way.
    One other question is instead of getting each values using an index e.g like below

    string(variables('var_catEquipArray')?[0])


    Can i do something like this below in power automate

    string(variables('var_catEquipArray')?[i])) 


    Loop through the array and passing the values to filter

    Thanks

  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at

    Hi @naijacoder 

     

    You can indeed.  You could define a variable at the beginning of your flow and increment the variable in a do until (variable is less than a number or for example length of array)

     

    DamoBird365_0-1617692652458.png

     

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    Cheers,
    Damien


    P.S. take a look at my new blog here

  • naijacoder Profile Picture
    172 on at

    Thanks. Will give it a shot

  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at

    Hi @naijacoder 

     

    How are you getting on?

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    Cheers,
    Damien


    P.S. take a look at my new blog here

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