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 / Using clear collect to...
Power Apps
Answered

Using clear collect to collect the FirstN item in a gallery

(0) ShareShare
ReportReport
Posted on by 35

Hi guys,

 

ClearCollect(30seconds, FirstN(Sort(BrowseGallery1.AllItems, 'Sum of Value', SortOrder.Descending),1));

 

Trying to collect the largest sum of value by sorting descending and collecting firstN limited to 1. Something is amiss. Help appreciated.

 

 

{Update: Fixed - Syntax for collection}

 

ClearCollect(Col30seconds, FirstN(Sort(BrowseGallery1.AllItems, 'Sum of Value', SortOrder.Descending),1));

 

Many thanks

Categories:
  • Verified answer
    v-mengmli-msft Profile Picture
    Microsoft Employee on at

    Hi @Jake_Daniels_9 ,

     

    Do you want to collect items in gallery with largest sum of value?

    Please try this:

    ClearCollect(30seconds, Filter(BrowseGallery1.AllItems, 'Sum of Value'=Max(BrowseGallery1.AllItems,'Sum of Value'))

     

    Best regards,

    Rimmon

  • Jake_Daniels_9 Profile Picture
    35 on at

    This did work except not as well as I expected 😞

     

    How do I show the max sum of value in the gallery?

     

    I tried this but it doesn't work,

     

    Onvisible for my first form I collect the data from the source SPlist.

     

    2nd form,

     

    Grouped by teams and score/

     

    AddColumns(
    GroupBy(Filter('Col30secs','Score Date'>=Today()-90),"TeamAliasText", "GroupedItems"),
    "Sum of Value",
    Max(Sum(GroupedItems,Points)))

     

     

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 405 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 368

#3
WarrenBelz Profile Picture

WarrenBelz 244 Most Valuable Professional

Last 30 days Overall leaderboard