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 / Find Max Value in Powe...
Power Apps
Answered

Find Max Value in PowerApps Gallery

(0) ShareShare
ReportReport
Posted on by 230

Hopefully a quick solve here, but I am trying to find the max value (actually a date) stored in labels in a gallery.

 

Using the following, the return is always "0""

 

Max(
 Gallery1_3.AllItems,
 Label2_12.Text
)
Screenshot 2022-07-28 190319.png
Categories:
I have the same question (0)
  • Verified answer
    Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @tlevine 

    First(Sort(Gallery.AllItems, datefield, Descending).datefield

  • tlevine Profile Picture
    230 on at

    hi @Drrickryp - i actually dont want to sort the gallery, im trying to find the actual max value of the field. hope that helps to clarify

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @tlevine 

    The formula @Drrickryp provided will give you the max date value.  You cannot use the Max or Min functions on a date like you were.  The trick is to just sort in your formula and take either the first or last depending on if you want max or min.

    The formula is not going to sort your gallery, just give you the max value.

  • tlevine Profile Picture
    230 on at

    makes sense - i wasnt thinking about the max or min applying to numbers. i will give this a try an then accept as a solution

  • PaulD1 Profile Picture
    2,914 on at

    This may/may not be relevant but I believe this will only work for the rows that are currently showing in the gallery.

    If the items property of the gallery is delegable, the gallery will load records in batches of 100 (the next batch being fetched as you scroll to the end of the current batch), so if you have a delegable source for the gallery and more than 100 rows and you haven't physically scrolled to the end, you will only get the Max of those 100 records currently in the gallery, not all records in the source.

    I've seen folk get caught out with this when building there App against a small set of test data and then find that it won't scale to larger datasets.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @PaulD1 

    Yes, this is a true statement.  If the gallery is paging (delegable simple formula) then referencing AllItems will only ever contain all the records *currently* in the gallery table.

    Considerations everywhere to always be make in the design! 😉

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!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 493 Most Valuable Professional

#2
11manish Profile Picture

11manish 479

#3
Haque Profile Picture

Haque 328

Last 30 days Overall leaderboard