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 / Looking for a way to r...
Power Automate
Unanswered

Looking for a way to remove values from an array.

(0) ShareShare
ReportReport
Posted on by

I am looking for a way to remove any non 10-digit values from an array.  In  this example I was to remove the 123@domain.com value but keep the 5551112222 values.

 

Here is the array:

ShawnD_0-1674669939417.png

 

Categories:
I have the same question (0)
  • Ventit Profile Picture
    422 on at

    What is the previous and What is your next step?  I assume you want to use the array values in something that would likely put it in a apply to each.  If so the field can be be set to null to remove teh email.

     

     

  • Verified answer
    grantjenkins Profile Picture
    11,063 Moderator on at

    When you say you want to remove the value - do you want to just remove the value from that particular object, or remove the entire object if it contains non-10-digit values?

     

    If you meant filter the array so only objects that contain a 10-digit value would remain, then you could do something similar to below.

     

    Compose contains your array of objects.

    grantjenkins_0-1674732063668.png

     

    Filter array uses the output from the Compose and applies the following filter.

    //Checks that the length of value is equal to 10, and
    //Checks that value is a valid float (number)
    
    @and(
     equals(length(string(item()?['value'])), 10),
     equals(isFloat(item()?['value']), true)
    )

    grantjenkins_1-1674732170739.png

     

    After running the flow, we would have the following output (excludes the object with invalid value).

    [
     {
     "waitTime": 0,
     "status": "A",
     "pathId": 2419001148045324,
     "countryCode": "US",
     "value": "5551112222",
     "skipValidation": false,
     "pathEnable": true
     },
     {
     "waitTime": 0,
     "status": "A",
     "pathId": 2419001148045319,
     "countryCode": "US",
     "value": "5551112222",
     "skipValidation": false,
     "pathEnable": true
     }
    ]


    ----------------------------------------------------------------------
    If I've answered your question, please mark the post as Solved.
    If you like my response, please consider giving it a Thumbs Up.

  • Community Power Platform Member Profile Picture
    on at

    Thank you.  I did find the use case where the 123@domain.com was the only result and was filtered out causing the flow to think it was an error.  To me this is fine but what is the best way to handle?

  • Community Power Platform Member Profile Picture
    on at

    Thank you.  I did find the use case where the 123@domain.com was the only result and was filtered out causing the flow to think it was an error.  To me this is fine but what is the best way to handle?

  • grantjenkins Profile Picture
    11,063 Moderator on at

    If you ended up with no results after the filter, you could check the length of the Filter array and only continue if the length was greater than zero.

  • Community Power Platform Member Profile Picture
    on at

    Hello,  

     

    Thank you for your repsonce.  Would you be able to provide me an example of how to check for the length was greater then zero please?

  • grantjenkins Profile Picture
    11,063 Moderator on at

    You can use the following expression to get the length of items from an array (including Filter array).

    length(body('Filter_array'))

     

    In the example below, if you only wanted to do something if the array contained at least one item (length is greater than zero) you would put all your actions within the Yes branch.

     

    grantjenkins_0-1675469607829.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 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard