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 Apps / combined collection (m...
Power Apps
Suggested Answer

combined collection (more than 2K) duplicating IDs

(0) ShareShare
ReportReport
Posted on by 557
Hello,  I have a list coming from SharePoint where there are more than 2K records.  Two collections were created for first 2K, and then for remaining and then a combined collection.  I am usning the combined collection as part of the items in gallery, but running into an issue where the IDs are repeating in the gallery.  Any ideas on below?
 
OnVisible – Screen:

ClearCollect(TempCollection,'eCom Intake'); //Create a temporary collection for the first 2,000 items
ClearCollect(RemainingItems, Filter('eCom Intake',ID > First(TempCollection).ID)); //Create another collection to store the remaining items (>2,000)
ClearCollect(CombinedCollection, TempCollection, RemainingItems) //Combine the two collections to get the desired range of items
 
Items Property in Gallery:

With(
    {
        _prefiltered_data: Filter(
             CombinedCollection,
            Status.Value = "Resolved",
            Len(Dropdown4_2.Selected.Value) = 0 || LOB.Value = Dropdown4_2.Selected.Value,
            Len(Dropdown4_3.Selected.Value) = 0 || 'Issue Type'.Value = Dropdown4_3.Selected.Value,
            !Checkbox1_1.Value || 'Created By'.Email=User().Email
       
        )
    },
    With(
        {
            _transformed_data: AddColumns(
                _prefiltered_data,
                TextID,
                Text(ID),
                CreatedByDisplayName,
                'Created By'.DisplayName,
                AssignedToDisplayName,
                AssignedTo.DisplayName,
                ChoiceString,
                'NeedMoreInfoOPS - Current'.Value
            )
        },
        With(
            {
                _filtered_by_names: Search(
                    _transformed_data,
                    SearchInput_tb_1.Text,
                    Title,
                    CreatedByDisplayName,
                    AssignedToDisplayName
                ),
                _filtered_by_id: Search(
                    _transformed_data,
                    SearchInput_tb_1.Text,
                    TextID
                )
            },
            With(
                {
                    _finaltable: If(
                        !SearchID_tg_1.Checked && !SearchRequestor_tg_1.Checked,
                        _filtered_by_names,
                        _filtered_by_id
                    )
                },
                SortByColumns(
                    _finaltable,
                    "ChoiceString",
                    SortOrder.Descending,
                    "ID",
                    SortOrder.Ascending
                )
            )
        )
    )
)
 
 
Categories:
  • Suggested answer
    Pstork1 Profile Picture
    69,665 Most Valuable Professional on at
    I see two problems here.
     
    1) If you wanted to get items in the second Collect that are Greater than the highest ID in the first collection you should use Last() not First().
     
    2) '>' is a non-delegable operator for the ID column in a Filter for SharePoint.  This is covered in the documentation. You need to use a different field to assemble your collection.
     
    But a bigger question is why do you want more than 2,000 records in the collection?  You should filter the collection so users can easily find what they want to work on, not scroll through 4.000 records trying to find a specific record.  Loading large local collections leads to several problems. First, they slow down the app. Second, they can lead to data corruption if more than one person is working on the data since they will each be working on a copy of the data not the original data. I know local collections is what a lot of people like to use, but its not a good practice and should only be used as a last resort.
  • Suggested answer
    Mark Nanneman Profile Picture
    993 Moderator on at
    Could you explain why you need to load all these records into a collection in the app's memory?  Why can't you just filter the SharePoint data source directly in your gallery's items property?

    In most cases you don't actually need to have 2000+ records loaded in your app's memory. 

    It looks like you're already filtering your collection in your gallery by the Status Value, the 'Issue Type' value, and also the Created by user plus other points.  If these filters are returning many records you might need to fine tune the filter to where it's only returning a manageable number of records for the user to work with.

    There are ways you can have the user update the record so that it no longer gets filtered into the gallery and it will drop out and make room for any other record that matches the conditions in the external database.


     You can also use the Search() function on your gallery to allow the user to search for a certain record.

    If you want to try to fix your current method:

    There's a few issues to note:

    A.  Your method isn't pulling the data from your sharepoint lists in any order.
    B.  There's no logical reason your first item in the "TempCollection" would have the highest ID in the set.
    C.  "ID >" is not delagable for SharePoint (unfortunately) so using this filter is not going to work the way you want on large data sets.
    D.  You shouldn't need more than one collection.

    You could try using a field like the Created on date column instead of the ID.

    Here's a test I did on a large SharePoint list I have that loads 6000 records into a collection.
    (it takes a minute to run, but it does work)

    I have a button, when clicked it:
    1.  clears my collection
    2.  Finds the created on string for the first record (ID=1)
    3.  Collects as many records as it can that were created on or after that time
    4. Finds the max created on date in that collection
    5. Collects again, this time using the previous max date as the filter.
    6. Repeats one more time.


    If this helped you, please click "Does this answer your question" and give it a like to help others in the community (+ close the ticket)!

    Power Platform Developer | LinkedIn: Mark Nanneman | Blog: Power Stuff  | YouTube: Mark's Power Stuff  

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 248 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 192 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard