Skip to main content

Notifications

Community site session details

Community site session details

Session Id : E6FODwRpROmWa5/ElRC1gv
Power Automate - Building Flows
Answered

Looking for a way to remove values from an array.

Like (0) ShareShare
ReportReport
Posted on 25 Jan 2023 18:06:33 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

 

  • grantjenkins Profile Picture
    11,059 Super User 2025 Season 1 on 04 Feb 2023 at 00:13:56
    Re: Looking for a way to remove values from an array.

    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

     

  • Community Power Platform Member Profile Picture
    on 03 Feb 2023 at 17:05:09
    Re: Looking for a way to remove values from an array.

    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,059 Super User 2025 Season 1 on 03 Feb 2023 at 11:59:02
    Re: Looking for a way to remove values from an array.

    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 30 Jan 2023 at 19:36:39
    Re: Looking for a way to remove values from an array.

    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 30 Jan 2023 at 19:36:37
    Re: Looking for a way to remove values from an array.

    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?

  • Verified answer
    grantjenkins Profile Picture
    11,059 Super User 2025 Season 1 on 26 Jan 2023 at 11:25:21
    Re: Looking for a way to remove values from an array.

    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.

  • Ventit Profile Picture
    402 on 25 Jan 2023 at 22:56:25
    Re: Looking for a way to remove values from an array.

    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.

     

     

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

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,668 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard