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 / Group and Sum a collec...
Power Apps
Answered

Group and Sum a collection

(0) ShareShare
ReportReport
Posted on by 30

Hi

Ive tried lots of different methods but i cant get any to work.

I have a collection - colProducts1 with the columns below

wailey1_0-1716462298913.png

wailey1_2-1716462346747.png

I have a vertical gallery that picks up the 'Title' (product), the 'Category' and the 'Quantity' of this collection

wailey1_3-1716462492671.png

I am trying to group the products by 'Title' and sum by the 'Quantity'.

My various attempts have managed to group by products, but the quantity wont show as its looking for a 'number'??

Or i can get it to add all the quantities together but not by grouped products.

Ideally id like the results in a new collection so i can display on a different page to the original collection.

Help please!!

 

 

Categories:
I have the same question (0)
  • Gochix Profile Picture
    1,937 Moderator on at

    @wailey1 ,

     

    This is a quick reply, but have you tried to use Distinct() function for the Gallery Items, and the a LookUp function for Quantity label?
    _____________________________________________________________________________________
    Please give a thumbs up if I resolved your issue! Please click Accept as Solution to close the topic!
     

  • VishalJhaveri Profile Picture
    1,169 Moderator on at

    ClearCollect(
    GroupedSalesData,
    GroupBy(SalesData, "Category", "GroupedItems")
    )

     

     

    ClearCollect(
    SummarizedSalesData,
    AddColumns(
    GroupedSalesData,
    "TotalAmount",
    Sum(GroupedItems, Amount)
    )
    )

     

    Try this out. It should work.

  • wailey1 Profile Picture
    30 on at

    Hi

    Thanks for replying so quickly, no i havent as i have no idea how to use distinct!!  Can you guide me through please i am a power app novice!

  • wailey1 Profile Picture
    30 on at

    Thanks so much for your reply.  I am a power apps novice, so where does this formula go - to a button 'on select' or can i put this into the 'items' for a new gallery?  GroupedSalesData is my new collection?  SalesData is my original collection 'colProducts1'?

  • Gochix Profile Picture
    1,937 Moderator on at

    @wailey1 ,

    You can do all that in the Gallery Items:

    AddColumns(
     GroupBy(
     colProducts1,Title,Category,'GroupedItems'),
     'TotalAmount',
     Sum(GroupedItems,Quantity)
     )


    _____________________________________________________________________________________
    Please give a thumbs up if I resolved your issue! Please click Accept as Solution to close the topic!

  • wailey1 Profile Picture
    30 on at

    Im so sorry, by brain isnt working.  Im assuming from setting up a new gallery i cant just put in 'Items' the formula beginning with 'Add Columns'.  Ive tried using the formula from  VishalJhaveri in the 'Items', but get the red error lines of doom.  Im going to be a right pain and ask from scratch and using my naming convention, what the steps are please? 

  • VishalJhaveri Profile Picture
    1,169 Moderator on at

    This goes in the Items property of the gallery.

  • Gochix Profile Picture
    1,937 Moderator on at

    @wailey1 ,

    That's correct, set a new gallery and put in items the formula I've provided.
    _____________________________________________________________________________________
    Please give a thumbs up if I resolved your issue! Please click Accept as Solution to close the topic!

  • wailey1 Profile Picture
    30 on at

    Thanks for your time.

    Im clearly not doing something right

    wailey1_0-1716471063807.png

    wailey1_1-1716471135964.png

    Do i need to do something in the gallery properties?

     

     

     

  • Gochix Profile Picture
    1,937 Moderator on at

    @wailey1 ,

    If you move the mouse on top where red underlines are, it should tell you what's the error.

    Can you provide that information, for me to look at it.

    I checked the formula at my side, so it's either wrong column names or something else.


    _____________________________________________________________________________________
    Please give a thumbs up if I resolved your issue! Please click Accept as Solution to close the topic!

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 April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 1,070

#2
Valantis Profile Picture

Valantis 639

#3
11manish Profile Picture

11manish 608

Last 30 days Overall leaderboard