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). 

Super User
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


Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020


Power Platform World Tour

Coming to a city near you


PowerApps Community User Group Member Badge

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


Join PowerApps User Group!!

Connect, share, and learn with your peers year-round


Power Platform Summit North America

Register by September 5 to save $200

Users Online
Currently online: 55 members 4,655 guests
Please welcome our newest community members: