cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Tushar18
Level: Powered On

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

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)

 

 

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Super User
Super User

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

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!
Community Support Team
Community Support Team

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

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
4 REPLIES 4
Super User
Super User

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

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
Level: Powered On

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

Thanks,

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

Super User
Super User

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

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!
Community Support Team
Community Support Team

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

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 172 members 3,854 guests
Please welcome our newest community members: