cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
anonymia25
Helper IV
Helper IV

Get latest entry from Sharepoint List based on a condition

Hello all,
I wanted a text label to show the latest description from the SP List which are currently based from one status, activity type and Ticket ID. My current formula works fine, but it shown the first entry for the selected Ticket ID. For example I have three rows for the current Ticket ID, but it will only shown the first/oldest one in the list.
How do I get the latest/new entry from the SP list based from the condition stated in the below formula?

 

If(LookUp(Ticket, ID = displayItem.ID).Status.Value = "Resolved", LookUp(Activity, 'Activity Type'.Value = "Resolution" && 'Ticket ID' = displayItem.ID).Description, "No resolution is available.")
 

 
Any help is greatly appreciated as always. Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions

I have fixed the issue for this and thanks again @Drrickryp for the clarification.
Turns out I misplaced sort function and used Created Date to display the latest order.

LookUp(Sort(Activity, Created, Descending),'Activity Type'.Value = "Resolution" && 'Ticket ID' = displayItem.ID).Description


Thanks. 

View solution in original post

3 REPLIES 3
Drrickryp
Super User
Super User

Hi @anonymia25 

Lookup will always find the first record that matches the criteria.  Since SharePoint, assigns a hidden sequential ID to every record, to obtain the latest one, sort the table by ID, Descending before applying the Lookup().  

Hi @Drrickryp ,

Thank you for the clarification, I have tried placing the sort function in my formula but it showed error. Not sure if its the correct way to place sort but I appreciate the help to guide me on this. Thanks.

If(LookUp(Ticket, ID = displayItem.ID).Status.Value = "Resolved", SortByColumns(LookUp(Activity, 'Activity Type'.Value = "Resolution" && 'Ticket ID' = displayItem.ID).Description, "No resolution is available."), Activity.'Ticket ID', Descending)

 

I have fixed the issue for this and thanks again @Drrickryp for the clarification.
Turns out I misplaced sort function and used Created Date to display the latest order.

LookUp(Sort(Activity, Created, Descending),'Activity Type'.Value = "Resolution" && 'Ticket ID' = displayItem.ID).Description


Thanks. 

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (4,606)