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 / Can't pick up the late...
Power Apps
Unanswered

Can't pick up the latest record from my sharepoint list on power apps

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi! My power apps formula can’t pick up the latest record from my sharepoint list. Here’s my context:

When an individual submits the form on power apps, the information will be recorded in my Sharepoint list. Hence, there can be multiple entries on sharepoint list by the same individual.

 

So my question is: How should my formula on power apps look such that it will pick up the latest record by the individual? My current formula looks like this:

If(LookUp(SharepointList, ID = DataCardValue16.Text, Status) = "Reserved" And DataCardValue22.SelectedDate - LookUp(SharepointList, ID = DataCardValue16.Text, DateofVisit)<60, "You can only make a booking once in every 2 months.","")

 

Thank you!

Categories:
  • BCLS776 Profile Picture
    8,994 Moderator on at

    This version may work better:

    If(
     LookUp(SharepointList, ID = DataCardValue16.Text, Status) = "Reserved" &&
     DateDiff(DataCardValue22.SelectedDate, LookUp(SharepointList, ID = DataCardValue16.Text, DateofVisit),Days)<60, 
     "You can only make a booking once in every 2 months.",
     ""
    )

    This only works if the DateofVisit column is properly formatted as a date/time value and the selected date is the same or later than the last booking.

    Hope that helps,

    Bryan

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you for your reply! I further refined my formula as I needed to check through 2 columns on my Sharepoint list. Also, in my sharepoint list it will contain multiple entries from the same individual. However, I have a problem with it:

     

    My current formula can’t fulfill the condition to book once every 2 months. For eg: I first make a booking for 1 Jan 2022 and make a second booking for 1 Oct 2021. If I make a third booking for 31 Dec 2021, instead of stopping this reservation from happening since my next booking is on 1 Jan 2022, my formula would allow this reservation to be submitted instead. Here's my current formula: 

    If(And((LookUp(Sort(SharepointList,DateofVisit,Descending), ID=DataCardValue16.Text,Status="Reserved") And (LookUp(Sort(SharepointList,DateofVisit,Descending), ID=DataCardValue16.Text,DateofVisit)-DataCardValue22.SelectedDate)<=60),((LookUp(Sort(SharepointList,DateofVisit,Descending), ID=DataCardValue16.Text,Status)="Reserved") And (DataCardValue22.SelectedDate-(LookUp(Sort(SharepointList,DateofVisit,Descending), ID=DataCardValue16.Text,DateofVisit))<=60))),"You can only make a booking once in every 2 months.",""))

     

    Do you have an idea on how should I refine it? Thank you!

  • BCLS776 Profile Picture
    8,994 Moderator on at

    OK, let's simplify things a bit using a With() to reduce repeating statements, Abs() to simplify the logic, and DateDiff() to correctly subtract date values from one another:

     

    With({ aSort: Sort(SharepointList,DateofVisit,Descending)},
    If(
     LookUp(aSort, ID=DataCardValue16.Text,Status="Reserved") && 
     Abs(
     DateDiff(
     LookUp(aSort, ID=DataCardValue16.Text,DateofVisit),
     DataCardValue22.SelectedDate,
     Days
     )
     ) <= 60,
     "You can only make a booking once in every 2 months.",
     ""
    )
    )

     This is free-typed, so the potential for some syntax issues, but this should be closer to working for you.

    Bryan

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 432 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 347

#3
WarrenBelz Profile Picture

WarrenBelz 254 Most Valuable Professional

Last 30 days Overall leaderboard