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 / How to find max number...
Power Apps
Answered

How to find max number from a collection

(0) ShareShare
ReportReport
Posted on by 72

 i have this collection and want to find max number without using max,sort function.

 

collection.PNG

Categories:
I have the same question (0)
  • AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at

    I don't think i am understanding correctly. Do you want a label outside the gallery to show the highest value for the column no but you don't want to sort or use max? can i ask why you don't wish to use them. 

  • MrShivam Profile Picture
    72 on at

    @AJ_Z  yes , but dont want to use max/sort

  • AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at

    I am trying to understand why we can't use max or sort. Is there a reason for this?

  • MrShivam Profile Picture
    72 on at

    @bipinshan 

  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @MrShivam :

    This is easy to implement, but the performance will be worse than Sort or Max. I've made a test for your reference:

    1\I assume there is a collection:

    ClearCollect(Number,{no:2},{no:6},{no:9},{no:6},{no:12});

    2\Add a button and set it's OnSelelct property to:

    ForAll(Number,If(no>Last(TheCollection).TheNumber,Collect(TheCollection,{TheNumber:no})));
    Set(TheResult,Last(TheCollection).TheNumber)

    3\Click the button, the maximum value in the collection 'Number 'will be saved to the variable 'TheResult'

    Best Regards,

    Bof

  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @MrShivam :

    This is easy to implement, but the performance will be worse than Sort or Max. I've made a test for your reference:

    1\I assume there is a collection:

     

    ClearCollect(Number,{no:2},{no:6},{no:9},{no:6},{no:12});

     

    2\Add a button and set it's OnSelelct property to:

     

    ForAll(Number,If(no>Last(TheCollection).TheNumber,Collect(TheCollection,{TheNumber:no})));
    Set(TheResult,Last(TheCollection).TheNumber)

     

    3\Click the button, the maximum value in the collection 'Number 'will be saved to the variable 'TheResult'

    Best Regards,

    Bof

  • MrShivam Profile Picture
    72 on at

    @v-bofeng-msft not working with negative numbers also it shows only last maximum number saved in that variable 'TheResult'. Can we use With function in ForAll to make further changes ?

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 356 Most Valuable Professional

#2
11manish Profile Picture

11manish 225 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 211

Last 30 days Overall leaderboard