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 / Selecting most recent ...
Power Apps
Answered

Selecting most recent duplicate SharePoint list entry and updating

(0) ShareShare
ReportReport
Posted on by

Hello Everybody,

 

I am updating a SharePoint list using the code below and this works.

Patch(RCAData, LookUp(RCAData, BatchID = DataCardValue16_2.Text && WaferID = DataCardValue28_2.Text),

The issue I have is it's possible to have duplicate entries in my list and this is a feature I want.

When I try to update the second entry then it updates the first entry instead, as I haven't specified which one to select. The update will always be for the last entry, so I want to do by date order. Can anyone advise the code for this and still keep the lookUp code for BatchID and WaferID.

 

Thank you in advance.

 

Rob

Categories:
I have the same question (0)
  • Geeks_D Profile Picture
    1,169 on at

    Hello, 
    You can try and sort the lookup formula in a descending order 
    Which of the ID is the unique ID for your Data source ? 

     

  • realwillwright Profile Picture
    772 Moderator on at

    Hi,

     

    Instead of having a lookup inside the patch, you could set a variable as the lookup and reference that.

     

    UpdateContext({lclItemToPatch:
     First(
     Sort(
     Lookup(RCADate, BatchId = DataCardValue16_2.Text && WaferId = DataCardValue28_2.Text), 
     Created, 
     Descending
     )
     )
    });
    Patch(RCData, lclItemToPatch, {})

     

    I always get Ascending and Descending the wrong way round, but something like this

  • rob4681 Profile Picture
    on at

    Thank you but the code uses a column for the sort function and this won't compile. I don't know why, I tried different columns.

  • realwillwright Profile Picture
    772 Moderator on at

    Could you try this to populate the variable, I've used SortByColumns rather than Sort. You can then try the patch function as per the previous reply. You will need to populate information into the {} section for the data you need.

     

    Created should be a column in a SharePoint list. 

     

    UpdateContext({lclItemToPatch:
     First(
     SortByColumns(
     Lookup(RCADate, BatchId = DataCardValue16_2.Text && WaferId = DataCardValue28_2.Text), 
     "Created",
     SortOrder.Descending
     )
     )
    })

     

  • rob4681 Profile Picture
    on at

    Hello again,

    I get the errors in the screen shot below

    rob4681_0-1698225436184.png

    Not too sure it sees my BatchID and WaferID as a table.

     

    Thanks

     

    Rob

  • Verified answer
    realwillwright Profile Picture
    772 Moderator on at

    Sorry it should be Filter rather LookUp

     

    UpdateContext({lclItemToPatch:
     First(
     SortByColumns(
     Filter(RCADate, BatchId = DataCardValue16_2.Text && WaferId = DataCardValue28_2.Text), 
     "Created",
     SortOrder.Descending
     )
     )
    })


    -------------------------------------------------------------------
    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.

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 Apps

#1
WarrenBelz Profile Picture

WarrenBelz 325 Most Valuable Professional

#2
11manish Profile Picture

11manish 165

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 88 Super User 2026 Season 1

Last 30 days Overall leaderboard