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 / Get items returning mo...
Power Automate
Answered

Get items returning more than 1 item

(0) ShareShare
ReportReport
Posted on by 178

I'm running to an issue where I'm running a Get items action for a sharepoint list and just want it to return one item.
Top Count = 1 

Pagination = 20,000

 

However, I keep getting a return of two items. It seems like top count doesn't work. Also, how can I just get the first item to return? I believe there's an expression I can use in the apply to each.

Objective:

I'm trying to capture the ID for the first item with a variable.

 

Get_Items.png

Categories:
I have the same question (0)
  • ScottShearer Profile Picture
    25,290 Most Valuable Professional on at

    @lui 

    I just ran a quick test and Top count dies work for me as designed.

    Try turning pagination off.  I don't believe that it should impact your results.

     

     

  • lui Profile Picture
    178 on at

    I need to since I have more than 5000 items in the SP list. Is it possible to add expression on the Apply to each step to get/select the first item?

  • ScottShearer Profile Picture
    25,290 Most Valuable Professional on at

    @lui 

    The 5000 limit refers to the fact that SharePoint will return a maximum of 5000 items.  You are filtering your results and limiting to 1 on the server side.  Therefore, pagination should not be necessary (you are returning a single item).

    @Pstork1 would you care to chime in?

     

     

  • lui Profile Picture
    178 on at

    @ScottShearer doesn't pagination allow us to grab more than 5000 times before the filter?

    The reason I began to use pagination because this sharepoint list (consists of 10000+ items) was not returning any items. Let's say I need two items to return: ID 100 and ID 10000. Without Pagination, the get items wouldnt return both regardless of the filter. Is this not correct?

  • Verified answer
    Pstork1 Profile Picture
    69,121 Most Valuable Professional on at

    So here is what I think is going on.  Turning on Pagination will divide up the records into paged groups and apply your OData filter to each group.  That's why you are getting 2 items returned.  They are the top item from each page.

     

    But when using an OData query you don't need to worry about pagination unless you are returning more records than the max record count. This is because the query is actually evaluated on the server.  So in your case the query will never return more than one record, but it will return up to one record for each page of results.

     

    I ran a test on a large list I have with 5,101 records in it and it worked fine only returning one record even with pagination turned off.

  • Tono_Analyst2 Profile Picture
    125 on at

    I have also observed the same behaviour as @lui.

     

    I have a test SharePoint list with exactly 20,000 records. I have created a column called Color which for testing purposes has exactly 7 records with the value Grey at the following IDs

    ID
    1
    6001
    19801
    19811
    19819
    19976
    20000

     

    I have tested multiple configurations of the Get Items action to test the behaviour, see outcome below:

     

    Filter QueryOrder ByTop CountPaginationLimitIDs Returned
    Color eq 'Grey'ID ascBlankOffN/aID: [1]
    Color eq 'Grey'ID descBlankOffN/a

    ID: [20000; 19976; 19819; 19811; 19801]

    Color eq 'Grey'ID desc2OffN/a

    ID: [20000; 19976]

    Color eq 'Grey' ID asc1On1ID: [1]
    Color eq 'Grey' ID ascBlankOn100All 7
    Color eq 'Grey' ID asc1On100100 records with duplicates?
    Color eq 'Grey' ID asc3On100All 7
    Color eq 'Grey' ID ascBlankOn1000All 7
    Color eq 'Grey' ID asc3On1000All 7
    Color eq 'Grey' ID ascBlankOn10000All 7
    Color eq 'Grey' ID asc1On10000Flow Run timeout
    Color eq 'Grey' ID asc3On10000All 7
    Color eq 'Grey' ID asc5On100008 records with a duplicate? [19801 duplicated]
    Color eq 'Grey' ID asc3On20000All 7

     

    From the above, it seems that:

    1. Without enabling pagination, you are only able to access the 5000 items prior to filtering and then the output be based on whatever is filtered from these 5000 items.
    2. Without enabling pagination, the top count will work as expected.
    3. With pagination enabled and no top count applied, it seems you can retrieve all of the expected data regardless of the pagination threshold limit. 
    4. With pagination enabled the top count seems to be ignored and sometimes even exhibits strange behaviour of causing duplicates.

    I do not understand how these settings should be configured and their limit. 

     

    Another approach is to create an indexed column which appears to solve the issue without requiring pagination at all. However, the limit of this approach is not clear to me. With 20,000 records it is working, but what happens if there were 1,000,000 records will this still work?

     

    Creating an indexed column seems to be the only approach that allows for the top count to work when dealing with 5000+ records

    Filter QueryOrder ByTop CountPaginationLimitColumn IndexIDs Returned
    Color eq 'Grey'ID ascBlankOffN/aColor indexedAll 7
    Color eq 'Grey'ID asc3OffN/aColor indexedID [1; 6001; 19801]

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!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 589

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 284 Super User 2026 Season 1

Last 30 days Overall leaderboard