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 items of a galle...
Power Apps
Answered

Group items of a gallery based on a attribute and add the same

(0) ShareShare
ReportReport
Posted on by 22

Hello,

 

I'm filtering data in the gallery according to selections in combo boxs/Dropdowns.

I want to group the items in gallery by color and add their total quantity.

 

For Example:

Product(Selected through dropdown)         Color         Quantity

A                                                                    X                        10

A                                                                    Y                        20

A                                                                    X                        12

 

This way it is stored in table and shown in gallery as well.

 

I want the items  Like this:

Product(Selected through dropdown)         Color         Quantity

A                                                                    X                        22

A                                                                    Y                        20

 

The Items property is set to:

Filter(DataSource,Product = ComboBox1.Selected.Result, ID = ComboBox2.Selected.Result,
Location = Dropdown3.Selected.Result)

 

 

 

 

Categories:
  • Verified answer
    yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hi @Tushar18 

     

    Can you try to update your expression as:
    AddColumns(GroupBy(Filter(DataSource,Product = ComboBox1.Selected.Result, ID = ComboBox2.Selected.Result,
    Location = Dropdown3.Selected.Result),"Color","Grouped"),"Count",Sum(Grouped,Quantity))
     
    Now, the Count column contains the sum of the quantity in all the records.
     
    Hope this Helps!
     
    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
  • Tushar18 Profile Picture
    22 on at

    Thanks,

    It worked but now I can't select other fields to show in gallery. Just These two.(See Attachment)

    Upload.PNG
  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hi @Tushar18 

     

    That is because groupby moves all the other columns to a nested table, based on the formula, the table is inside column, grouped. If you want to access a specific column out of it, then you can use AddColumns(). If you need specific help with the formula here, please share the schema of the datasource along with the key that you want to fetch after this grouping.
     
    Hope this Helps!
     
    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
  • Verified answer
    v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @Tushar18 ,

    Based on the issue that you mentioned, I have made a test on my side, I think a nested Gallery could achieve your needs. Please consider take a try with the following workaround:

    Set the Items property of the Gallery (Gallery1) to following formula:

    AddColumns(
    GroupBy( Filter(DataSource, Product = ComboBox1.Selected.Result, ID = ComboBox2.Selected.Result, Location = Dropdown3.Selected.Result), "Color", "GroupData" ),
    "Total Quantity",
    Sum(GroupData, Quantity)
    )

    Then within your above Gallery (Gallery1), you could consider add an nested Gallery (Gallery2), set the Items property to following:

    ThisItem.GroupData

    within this nested Gallery (Gallery2), you could add some Label controls to display other column values from your DataSource. Set the Text property of the Label to following formula:

    ThisItem.Product
    ThisItem.ID
    ThisItem.Location

    ....

    ....

     

     

    Best regards,

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 396 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 323

#3
WarrenBelz Profile Picture

WarrenBelz 193 Most Valuable Professional

Last 30 days Overall leaderboard