web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Last function not pick...
Power Apps
Answered

Last function not picking up last record consistently in Dataverse?

(0) ShareShare
ReportReport
Posted on by 503

Hello 

 

I am trying to retrieve the latest record once inserted into dataverse using the collect method. 

 

Here is the code that im using to try and retrieve the data into a gallery. 

 

 

Last(SortByColumns(Filter('Stagings','Employee Code'=TextInputEmployeeCode.Text, 'Generic Entry'="Record Entered"),"dlg_genericentry",Descending))

 

 

 

But this seems to not pick up the latest records every time, only sometimes which i'm finding strange. So sometimes it will pick up the second latest record instead of the latest. 

 

I've also tried - 

 

 

Last(SortByColumns(Filter('Stagings','Employee Code'=TextInputEmployeeCode.Text, 'Generic Entry'="Record Entered"),"dlg_genericentry",Ascending))
First(SortByColumns(Filter('Stagings','Employee Code'=TextInputEmployeeCode.Text, 'Generic Entry'="Record Entered"),"dlg_genericentry",Descending))
First(SortByColumns(Filter('Stagings','Employee Code'=TextInputEmployeeCode.Text, 'Generic Entry'="Record Entered"),"dlg_genericentry",Ascending))

 

 

The same thing happens with these formulas^

 

As you can see in the screenshots, the record from 4:59pm is being retrieved in the gallery but the record from 5:00pm should be retrieved because its the latest record in the table. 

 

A flow creates the log out record and the login record is created inside the powerapp if this matters. 

 

I hope someone can help! 

Much appreciated

Categories:
I have the same question (0)
  • v-bofeng-msft Profile Picture
    on at

    Hi @Usernametwice23 :

    Do you want to get the latest record?If so,please try

    First(
     Sort(
     Filter('Stagings','Employee Code'=TextInputEmployeeCode.Text, 'Generic Entry'="Record Entered"),
     'Created On',
     Descending)
    )

     Best Regards,

    Bof

  • Verified answer
    Usernametwice Profile Picture
    503 on at

    Hi Thank you for that. 

     

    It turns out I had to be using a date field with <=Now()) function. 

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard