Showing results for 
Search instead for 
Did you mean: 
Level: Powered On

Patch last record on CDS

Hi, my question is very simple, but I could not find anything helpful. I would like to patch the last record that has a blank field in my CDS entity. The scenario is this: I have several records with the same value in a field (let's say fieldA) and I want to write to an another field (fieldB) only on the most recent one. Consider that the field I mentioned are all the equals, what changes is the creation date. How can I achieve that? The Last function is not delegable, so it doesn't always do what I want (almost never). 

Dual Super User
Dual Super User

Re: Patch last record on CDS

Hi @mark6 


You can try using the formula:
Patch(DataSource, First(Sort(Filter(DataSource, Field1 = "<<ValueToMatch>>"),'Modified On',Descending)),{Field2:"<<valueToUpdate>>"})
Here, please replace DataSource with your actual Data Source name and you can get the last updated record, using OOTB attibute "Modified On".
Hope this Helps!
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
Level: Powered On

Re: Patch last record on CDS

Hi  ,

thanks for your answer. I tried your formula but the behaviour is always the same. The strange thing is that on my computer it does work, but when I execute on my device (Samsung tablet) it doesn't work. In particular it patches another record, the first one, not the latest. I cannot figurate why. I inserted a Refresh(entity) before the operation but the problem still remains. Any other suggestion?

Helpful resources

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.


Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!


Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020


Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.


Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Users online (9,641)