cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Dual Super User III
Dual Super User III

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

Highlighted
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
Highlighted
Dual Super User III
Dual Super User III

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

Highlighted
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)

Highlighted
Dual Super User III
Dual Super User III

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!
Highlighted
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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

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