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 / Getting Last Record fr...
Power Apps
Answered

Getting Last Record from SQL Database

(0) ShareShare
ReportReport
Posted on by 144

Hi all!

 

I have what I am sure is a very quick and easy question!

 

I have a SQL table with a list of visits to customers.

What I need to do is pull back the last record for that customer and then show the date column

 

For example:

custnamecustiddate
Comp1120/02/2020
Comp1120/03/2020
Comp2219/01/2020
Comp2227/02/2020
Comp3330/03/2020

 

So for instance I want to do a Lookup for custid = 2 and Return the last entered date column.
This would return 27/02/2020, is this possible.

 

The only way I have made this happen so far is with the following code:

 

ClearCollect(
 LastVisit,
 LastN(
 Filter(
 '[dbo].[visitlog]',
 custid = Text(ThisItem.ID)
 ),
 1
 ).date

 

 

Obviously this then adds it to a collection, I can then return that collection into a Drop down and Then that drop down into a Label Field.

This just seems a long winded way to get what I need.

 

Any help is much appreciated! 

 

Cheers,
Danny

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    153,051 Most Valuable Professional on at

    Hi @MrDannyHarry ,
    I am a SharePoint user, but this may work (it does on my large test list).
    Also, date is not a good title for a field - it is a reserved word.

    First(
     Sort(
     Filter(
     '[dbo].[visitlog]',
     custid = Text(ThisItem.ID)
     ),
     date,
     Descending
     )
    ).date

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • MrDannyHarry Profile Picture
    144 on at

    @WarrenBelz 

     

    New it would be something simple!!!

    Thanks for the tip on the column name! Will change this as well.

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 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard