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
Dual Super User
Dual 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!

View solution in original post

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.

View solution in original post

4 REPLIES 4
Dual Super User
Dual 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!

View solution in original post

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)

Dual Super User
Dual 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.

View solution in original post

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (5,811)