cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
vsslasd
Level 8

GroupBy in Gallery

Am confused by GroupBys in PowerApps.

We are trying to create a simple GroupBy in  a gallery. The source data is in a collection called ECollection and it has a number of fields/columns in it: 

 

 
CustomerId,
LocationId,
PRM_Asset_Id,
EID,
Service_Call_ID,
LocationName,
CustomerName,
Branch,
LocationStatus,
Manufacturer_ID,
EType,
Model_Number,
Serial_Number,
Expiration,
Install_Date,
Location,
Bar_Code,
Optimal,
RType,
AssetId,
Verified,
ManufactureDate,
Size,
Installed_By,
Description,
MDFUSRID,
Timestamp
 
We have a gallery and we just want to display only two fields in the gallery:
the EType and the count of the items for each EType. 
 
EType     Count
A               7
B               3
D             16
 
What is the simpliest way for us to do this ? Can a Gallery have a group by statement in the "Items" property, or is it best to perform the GroupBy on a new collection from the ECollection ?
 
And what would the forumla be?
 
Thank you
1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: GroupBy in Gallery

For the items property of the Gallery:

GroupBy(ECollection,"EType","grp")

Then add two labels to the gallery, in the first set the text property as follows:

ThisItem.Etype

And in the second (to give the count) set the text property as follows:

CountRows(ThisItem.grp)

The GroupBy gives you a hierarchical recordset in which all the grouped columns/rows go into a 'subtable' called "grp' (or whatever name you use in the last argument of your GroupBy.

View solution in original post

5 REPLIES 5
NigelP
Level 8

Re: GroupBy in Gallery

Hi @vsslasd

 

@Mr Dang has just done a master class in GroupBy - this should help

-> https://powerusers.microsoft.com/t5/General-Discussion/Combining-Fields-Into-a-Record/m-p/212359/hig...

 

Regards

 

Nigel

vsslasd
Level 8

Re: GroupBy in Gallery

Thank you. I'm looking at it. It's a bit confusing.

Super User
Super User

Re: GroupBy in Gallery

For the items property of the Gallery:

GroupBy(ECollection,"EType","grp")

Then add two labels to the gallery, in the first set the text property as follows:

ThisItem.Etype

And in the second (to give the count) set the text property as follows:

CountRows(ThisItem.grp)

The GroupBy gives you a hierarchical recordset in which all the grouped columns/rows go into a 'subtable' called "grp' (or whatever name you use in the last argument of your GroupBy.

View solution in original post

vsslasd
Level 8

Re: GroupBy in Gallery

Thank you! Much simple !

vsslasd
Level 8

Re: GroupBy in Gallery

That works totally great!

The column on the left works fantastic and the countrows works perfectly.

 

We need to also count the rows if the Verified column = true.

 

Just a little confused on how that needs to be handled in PowerApps. I'm thinking the Verified column needs to be converted to a number in the original collection, and then it can properly be summed up in the groupby Gallery ?

 

My gallery items = GroupBy(ECollection, "EType","grp")

 

verified.png

 

Thank you

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 (4,698)