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 / How to loop through an...
Power Automate
Answered

How to loop through an array skipping the first two elements with Power Automate?

(0) ShareShare
ReportReport
Posted on by 173

I'm parsing an email message.  This message can contain multiple alert messages.  I have found a way to split the html_to_text so I have each alert as a separate array element.  However, the text I am splitting on is also earlier in the body so I end up not needing the first two array elements.  If there is only one alert I need array element 3, if there are three I need elements 3, 4 & 5.  Ultimately the array element data will be inserted into a sql server database.  

 

I'm thinking I need to use an Apply To Each action.  The problem is I don't know how many elements there will be, just that I need to skip the first two.

 

Any ideas how to skip the first two?  Thanks!

 

 

 

Categories:
I have the same question (0)
  • Verified answer
    RichardUchytil Profile Picture
    173 on at

    Found it!  I need to use skip(variables('Array'),2).  

  • Mira Ghaly Profile Picture
    11,415 Moderator on at

    @RichardUchytil 

    Please find below the logic you need to do to skip first 2 items in the array.

    1. Initialize a count variable outside of your array

    Mira_Ghaly_0-1630532084239.png

    2. Inside the apply to each 

    1. Add a compose data operation as below

    add(variables('count'),1)

    2. Set the count variable to the output of the compose operation

    3. Add a condition if count = 3 then do your logic , on the yes branch, this will skip the first 2 items in the array

    Mira_Ghaly_3-1630532699506.png

     

    Hope this works for you!

     

  • RichardUchytil Profile Picture
    173 on at

    I'm sure that works but seems much more complex than what I found.  Then again, maybe what I found won't work all the time or is even correct?

     

    1. I get the email.
    2. Convert the html to text.
    3. Initialize a variable converting the text to an array using split.
    4. In my Apply to each I set the output from previous steps to skip(variable('NumberOfAlerts'),2).  
    5. Then for testing added a send email step where I'm sending the CurrentItem.

    That worked for me.  Is that way bad or wrong?  I'm still very new to Power Automate, so could be I'm doing it wrong.

     

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 630

#2
Valantis Profile Picture

Valantis 420

#3
11manish Profile Picture

11manish 350

Last 30 days Overall leaderboard