Skip to main content

Notifications

Community site session details

Community site session details

Session Id : 6M7L19aQFEJmWTEZClHoiA
Power Apps - Building Power Apps
Answered

Find Max Value in PowerApps Gallery

Like (0) ShareShare
ReportReport
Posted on 28 Jul 2022 23:03:43 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
)
Categories:
  • RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on 29 Jul 2022 at 15:17:46
    Re: Find Max Value in PowerApps Gallery

    @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! 😉

  • PaulD1 Profile Picture
    2,914 on 29 Jul 2022 at 05:06:13
    Re: Find Max Value in PowerApps Gallery

    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.

  • tlevine Profile Picture
    230 on 29 Jul 2022 at 00:05:26
    Re: Find Max Value in PowerApps Gallery

    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

  • RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on 29 Jul 2022 at 00:02:23
    Re: Find Max Value in PowerApps Gallery

    @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 28 Jul 2022 at 23:51:28
    Re: Find Max Value in PowerApps Gallery

    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

  • Verified answer
    Drrickryp Profile Picture
    Super User 2024 Season 1 on 28 Jul 2022 at 23:37:02
    Re: Find Max Value in PowerApps Gallery

    @tlevine 

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

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,745 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,091 Most Valuable Professional

Leaderboard