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 do I extract only ...
Power Automate
Answered

How do I extract only the first few items in a list

(0) ShareShare
ReportReport
Posted on by 65

Hello,

I am trying to use the 'Extract data from webpage' action to extract just the first few items from a list of span elements on a webpage. Every time I select up to the second item, it automatically selects all the items for extraction. I do not need all the items, just the first 10 items. How do I go about this, please?

 

I have the same question (0)
  • lbendlin Profile Picture
    8,726 Super User 2026 Season 1 on at

    Add a loop counter variable to your flow.  Exit the loop at the appropriate moment.

  • VJR Profile Picture
    7,635 on at

    Hi @donaldekpe 

     

    Every time I select up to the second item, it automatically selects all the items for extraction

    This is by design that PAD automatically detects and gives us a table based on the first two selections.

     

    Here are some options for what you are trying to do.

    1. Extract just the first item. See its html in the Advanced Settings and likewise get the second item. 

    Eg;

    /..../Div(0)/Input(0) -> if this gives the first item

    /..../Div(0)/Input(1) -> then get the second item separately 

     

    Either use a separate Extract data from webpage or use the Handpicked values option of the Extract data from webpage to extract both at once

     

    VJR_0-1664163450084.png

     

     

    2. If you are having trouble with that then to get the first few items of a list below is the syntax

    If MyList is your list then use %MyList[0:2]% to get the first two items.

     

     

  • donaldekpe Profile Picture
    65 on at

    Thank you for the response. How do I do this though. Do I add the extract action into the the loop and then select the first item to be extracted while the loop extracts the rest?

  • donaldekpe Profile Picture
    65 on at

    Thank you for the reply. I have tried using the handpicked option but I noticed it only extracts the values into just one row rather than in one column like a list would look like. I want to loop through the values extracted and so having everything in just one row would make it look like a single value only. I hope you get me.

     

    You wrote something about a syntax. I believe that could help but how do I use that syntax, where do I put it, is it javascript? Sorry, I am a bit of a noob here, but I learn fast.

  • VJR Profile Picture
    7,635 on at

    For the syntax part of the answer:

     

    Do what you were originally doing ie; 

    "'Extract data from webpage' action ....Every time I select up to the second item, it automatically selects all the items for extraction"

    When you run this action in PAD it will give you the result in a datatable.

    Then you can use a For each loop on the datatable and just get the top required rows. ie; If you need top 3 items then exit the loop after 3 iterations of the loop.

  • donaldekpe Profile Picture
    65 on at

    Ok, I get that. I actually want to continually loop through the first ten items without exiting, at least not until the flow itself is stopped.. Is there a way to do this?

  • VJR Profile Picture
    7,635 on at

    - Have a Counter variable set to 10

    - Within the loop have a If condition to check if the value of Counter is greater than 10. If yes, use Exit Loop.

    - Just before the loop end, increment the counter by 1

  • donaldekpe Profile Picture
    65 on at

    Thank you for the help. I will give that a try.

  • Henrik_M Profile Picture
    2,021 Super User 2024 Season 1 on at

    I remember seeing this syntax a long while back. Where did you discover it? 😅

  • Verified answer
    VJR Profile Picture
    7,635 on at

    At first saw it on the forum itself 😊 and then found it here 

     

    https://learn.microsoft.com/en-us/power-automate/desktop-flows/variable-data-types

    VJR_0-1664766008562.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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 262 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 167

#3
Haque Profile Picture

Haque 154

Last 30 days Overall leaderboard