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 / Filtering Sorting and ...
Power Apps
Answered

Filtering Sorting and Selecting Last (Latest) item in a collection and using the value in a text label

(0) ShareShare
ReportReport
Posted on by 301

Hi,

 

I have an app that needs to display in a text label the last item from a collection so i can then reuse that item to show what the next item should be for e.g.

 

My data is like this

 

CreatedBoxIDSome Other Column

1/1/2000

Bx00001zzz
1/1/2001Bx00002233
1/1/2002Bx0000342343

 

I cannot figure out how to sort the collection by the created date and display the text value in a label, do i need to put it in a gallery or a datatable first?

 

I dont right? i can just ClearCollect and Sort and filter and Lookup? if someone could help that would be great.

 

For example i want the item Bx00003 in a text label.

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

    Hi @ShaneITAutomate ,

    This should work

    First(
     Sort(
     YourListName,
     Created,
     Descending
     )
    ).BoxID

     

    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.

    Visit my blog Practical Power Apps

  • ShaneITAutomate Profile Picture
    301 on at

    Cheers Warren, you always are a great help. Could i do something like below?

    ClearCollect(Collection1, datasource),
    Collect(Collection2),
    First(
    Sort(Collection1,Created,Descending)
    ).BoxID

     

    (Sorry about the formating the code clearly aint right)

     

    Currently im using the Onstart Function and Clearcollecting and then below that im sorting. It feels wrong for some reason however it works.

  • WarrenBelz Profile Picture
    154,928 Most Valuable Professional on at

    Hi @ShaneITAutomate ,

    The second item is not a collection - it is a single value - you could make a Variable with it

    ClearCollect(
     Collection1, 
     datasource
    );
    Set(
     gblBoxID,
     First(
     Sort(
     Collection1,
     Created,
     Descending
     )
     )
    ).BoxID

     

    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.

    Visit my blog Practical Power Apps

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 551

#2
WarrenBelz Profile Picture

WarrenBelz 430 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 298

Last 30 days Overall leaderboard