cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Tushar18
Frequent Visitor

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

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
Frequent Visitor

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

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
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

‘Better Together’ T-Shirt Contest – Winner Announced!

‘Better Together’ T-Shirt Contest – Winner Announced!

And the winner is...

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Power Platform 2020 release wave 1 plan

Power Platform 2020 release wave 1 plan

Features releasing from April 2020 through September 2020

Top Solution Authors
Top Kudoed Authors
Users online (6,288)