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 / Unable to delete from ...
Power Apps
Suggested Answer

Unable to delete from a collection - Powerapp Specified record was not found error

(1) ShareShare
ReportReport
Posted on by 595
I have a powerapp where i have a collection. The issue is i am unable to delete a record from a collection. It says "Specified record was not found" when sorting is enabled on the Gallery Items property. Note: Date of review conducted is a single line of text column.
 
If i remove the sorting code piece, it works fine and i am able to delete a record from a collection. May i know why?
 
Gallery Items with Sorting enabled
If(
    IsBlank(DatePicker1_6.SelectedDate),
    SortByColumns(
        AddColumns(
            Filter(
                yourEditCollection,
                System_List_ID = DBvaredititem.ID
            ),
            DateSort,
            DateValue('Date of review conducted')
        ),
        "DateSort",
        SortOrder.Descending
    ),
    Filter(
        yourEditCollection,
        'Date of review conducted' = DatePicker1_6.SelectedDate
    )
 
Gallery Items with no Sorting
If(
    IsBlank(DatePicker1_6.SelectedDate),
    Filter(
        yourEditCollection,
        System_List_ID=DBvaredititem.ID
    ),
    Filter(
        yourEditCollection,
        'Date of review conducted' = DatePicker1_6.SelectedDate
    )
)
 
 
 
I have the same question (0)
  • Suggested answer
    11manish Profile Picture
    939 on at
    This is a known behavior in Microsoft Power Apps when using AddColumns + SortByColumns on a collection
     
    Reason:
    When you use:
    SortByColumns(
        AddColumns(...),
        ...
    )
    The gallery is no longer bound to the original collection (yourEditCollection)
    It is bound to a transformed table (new in-memory records)
    So:
    ThisItem ≠ actual record from yourEditCollection
    It’s a copy with an extra column (DateSort)
     
    Why Delete Fails
    When you do:
    Remove(yourEditCollection, ThisItem)
     
    Power Apps tries to:
    • Match the full record structure
    But:
    • Original record ≠ transformed record
    Result: "Specified record was not found"
     
    Recommanded solution:

    Use RemoveIf with a Unique Identifier 

    RemoveIf(
        yourEditCollection,
        ID = ThisItem.ID
    )
    Why this works:
    • Matches based on key field
    • Ignores transformation differences
    • Works with sorting, filtering, AddColumns
    If you don’t have ID 
    Use a unique combination:
     
    RemoveIf(
        yourEditCollection,
        System_List_ID = ThisItem.System_List_ID &&
        'Date of review conducted' = ThisItem.'Date of review conducted'
    )
     
    Better Design (Recommended Improvement)
    Instead of recalculating in Gallery:
    Step 1: Prepare collection once
     
    ClearCollect(
        colServiceView,
        AddColumns(
            yourEditCollection,
            DateSort,
            DateValue('Date of review conducted')
        )
    )

    Step 2: Bind Gallery

    SortByColumns(
        Filter(colServiceView, System_List_ID = DBvaredititem.ID),
        "DateSort",
        Descending
    )
     
     
  • Suggested answer
    Haque Profile Picture
    1,520 on at
     
    Let's find the out the root cause why it happens:
     

    When we enable sorting on the Gallery's Items property, the displayed order of records changes. However, if we try to delete a record by referencing the original collection (unsorted), the record identity may not match because the Gallery is showing a sorted version. This mismatch causes Power Apps to fail to find the record in the sorted collection, resulting in the error.

     

    How to address:

    Let's delete from the sorted collection, not the original: Please use the Gallery's AllItems or the sorted collection as the source for deletion, so the record reference matches the displayed data.

    Let's use the Gallery's selected item or ThisItem: When deleting, refer to the record as ThisItem inside the Gallery or use the selected item from the sorted collection.

     

    Example deletion formula
    Suppose your collection is colReviews and your Gallery's Items property is:

    Sort(colReviews, 'Date of review conducted', Descending)
     

    Then, to delete a record from the collection, use:

    Remove(colReviews, ThisItem) // This will work because ThisItem refers to the current record in the Gallery, which is sorted.

     

    So when Gallery Items with Sortin enabled,  remove by a unique identifier, not by record object, meaining, instead of passing the whole record, remove the item by matching a unique key or ID field that exists in your collection.

    Example: RemoveIf(yourEditCollection, ID = ThisItem.ID) //--please note that, if no unique id exist, please create one it will make the life easy.

     

     

    I am sure some clues I tried to give. If these clues help to resolve the issue brought you by here, please don't forget to check the box Does this answer your question? At the same time, I am pretty sure you have liked the response!
  • Suggested answer
    Kalathiya Profile Picture
    1,696 Super User 2026 Season 1 on at
     
    Yes, this can happen when you are doing sorting with a date column and some values are empty. That time it may throw an error while sorting or it may not work as expected. You might be facing the same issue.
     
    Could you please try to update the below code and just try it.
     
    Gallery Item Property: 
    If(
        IsBlank(DatePicker1_6.SelectedDate),
        SortByColumns(
            AddColumns(
                Filter(
                    yourEditCollection,
                    System_List_ID = 100
                ),
                DateSort,
                IfError(DateValue('Date of review conducted'), Blank())//DateValue('Date of review conducted')
            ),
            "DateSort",
            SortOrder.Descending
        ),
        Filter(
            yourEditCollection,
            'Date of review conducted' = Text(DatePicker1_6.SelectedDate, "yyyy-mm-dd")
        )
    )
     
    Remove Item Code: 
    RemoveIf(yourEditCollection,ID=ThisItem.ID)
    
    //ID = ThisItem.ID --- Please use your unique field (Like ID) for comparison based on your data setup, so the correct record is removed from the collection.
    If this response resolves your issue, please mark it as the Verified Answer so it can help other community members as well.
    ---------------------------------------------------------------------------------

    📩 Need more help? Just mention @Kalathiya and I’ll be happy to assist.

    ✔️ If this answer helped you, please tick “Does this answer your question?” so it can be marked as the Verified Answer.

    💛 A Like always motivates me to keep contributing!

    ​​​​​​​

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 Apps

#1
11manish Profile Picture

11manish 556

#2
WarrenBelz Profile Picture

WarrenBelz 412 Most Valuable Professional

#3
Haque Profile Picture

Haque 296

Last 30 days Overall leaderboard