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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Remove Item From List ...
Power Automate
Answered

Remove Item From List Using Logical expressions with contains

(0) ShareShare
ReportReport
Posted on by 431

I have a list that I am iterating but it is too slow. So I want to preprocess the list and remove items that I know are of no interest.

For example, I want to delete all items that contain "progressive" OR all items that have a length less than 4.  Is there a way to include Coontains and logic expressions in the value box. If yes what is the syntax? Or do I have to write a loop and delete items using the index number?

 

 

Steve48_0-1698509365464.png

 

I have the same question (0)
  • UshaJyothiKasibhotla Profile Picture
    225 Moderator on at

    Loop through the item values

    The. Use if activity write condition if listvariable contains progressive. then use remove item from the list. 

    Or

    Use for each 

    Take if activity then take your variable.length <4

    Then remove the item from list 

    Hope this helps 

    Usha 

  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    Removing item based on value only supports using the literal value. So, if you do not have a specific value that would be an exact match, you do in fact need to build a loop to remove the items.

     

    Alternative options would be joining the list into a string, then using Replace text with regex to remove the items, and then splitting the text into a list again.

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @Steve48 

     

    You can try the approach what @UshaJyothi20  suggested. Apart from that, we can try that using python code in power automate desktop. See below 

     

    Nived_Nambiar_0-1698562769081.png

     

    Step1: assign a list variable with some sample values like below

    Nived_Nambiar_1-1698562794065.png

     

     

    Step2: Join the list using colon as seperator

    Nived_Nambiar_2-1698562823906.png

     

    Step 3: use python script which filters out the data from list like below

    Nived_Nambiar_3-1698562860181.png

     

    The above code will split the JoinedText by : and then use List comprehension to filter out elements which has Progressive elements on it and which has length of element <4 

     

    The output of python script is stored in %PythonScriptOutput% variable which is a string. 

    Now use that variable to split it based on colon again using split text action like below and store the result in same List variable like below

    Nived_Nambiar_4-1698562986234.png

     

    Note: use Trimmed method on %PythonScriptOutput% as i had shown above to remove the new line generated in %PythonScriptOutput% output 🙂

     

    Hope this helps !

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

     

  • Steve48 Profile Picture
    431 on at

    Hi @Agnius 

    You answered my question. I need a loop. Thank you.

  • Steve48 Profile Picture
    431 on at

    Hi @UshaJyothi20 I ended up adding a loop as show below. I collected all of my matching elements in one variable called "criteria' which makes the code a bit neater.

    Steve48_0-1698612189172.png

     

  • Steve48 Profile Picture
    431 on at

    Hi @Nived_Nambiar cc @Agnius 

    I ended up using a loop which I included in y reply to @UshaJyothi20 

    However I plan to try the python approach too.  I only have Python 3 installed si will install Python 2. I wonder when Python 3 will introduced to PAD. In trying to understand how to use the Run Python script Ation I hadn't understood that the output was the result of print. Thank you for your help.

    Steve

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 604

#2
Valantis Profile Picture

Valantis 502

#3
Vish WR Profile Picture

Vish WR 417

Last 30 days Overall leaderboard