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

Summarizing Items based on a group

I don't know if this is possible but I'd like to try to recreate something similar to a pivot table in PowerApps using a gallery.  I would like each gallery entry to be the top level (company) with a secondary level below it (employee).  The data would be aggregated at a company level and an employee level.   The end result would look like this.

 

ABC 8
 Joe1
 Frank3
 Steve4
ZXY 8
 David3
 Mark2
 Craig3

 

I can sum up the top level using group by but I'm not sure how to list the rolled up hours for each employee within the gallery.  Anyone have any ideas?  Bonus points for being able to add a today filter to the gallery.  

 

 

Edit: I think I found the answer:

https://powerusers.microsoft.com/t5/Videos/PowerApps-Gallery-SubGallery-using-GroupBy-and-Flexible-H...

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Summarizing Items based on a group

Hi @dyee4614 ,

Do you want to only display one employee's max hour?

I've made a similar test for your reference:

1)my collection:

ClearCollect(test2,{Company:"ABC",Employee:"Joe",Hours:5},
{Company:"ABC",Employee:"Joe",Hours:3},
{Company:"ABC",Employee:"Frank",Hours:1},
{Company:"ZXY",Employee:"David",Hours:4},
{Company:"ZXY",Employee:"David",Hours:4},
{Company:"ZXY",Employee:"David",Hours:3},
{Company:"ZXY",Employee:"Mark",Hours:5})

2)gallery1's Items:

GroupBy(test2,"Company","CompanyGroup") 

2)insert gallery2 inside gallery1

Set gallery2's Items:

Distinct(CompanyGroup,Employee)

3)insert a label inside gallery1 to sum the max hours

set the label's Text:

"sum max hours:"&Sum(ForAll(Gallery2.AllItems,LookUp(test2,Employee=Result,Max(Hours))),Value)

4)insert two labels inside gallery2, one to display name, one to display max hours

set label1's Text:

ThisItem.Result

set label2's Text:

LookUp(test2,Employee=ThisItem.Result,Max(Hours))

 

Then the result is the same structure like your listed.10103.PNG

 

 

 

Best regards,

Community Support Team _ Phoebe Liu
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

3 REPLIES 3
dyee4614
Level: Powered On

Re: Summarizing Items based on a group

Here is where I'm at.

 

Gallery #1: Item =

GroupBy(DataSource,"Company","CompanyGroup") 

This gives me the company.

Inside the gallery, I made a second gallery

Item = CompanyGroup

ThisItem.Employee, MAX(Hours)

This works.  However, if I have multiple employees I will get multiple line items.  

Ex: 

Company ABC

        Joe  Hours: 4

        Joe Hours:  4

       Mark Hours: 5

Company XYZ

     Joe Hours 4

 

I'm so close!  I've tried doing a second group by or a filter which will fix the issue with multiple pack entries, however then my MAX of hours doesn't work

Community Support Team
Community Support Team

Re: Summarizing Items based on a group

Hi @dyee4614 ,

Do you want to only display one employee's max hour?

I've made a similar test for your reference:

1)my collection:

ClearCollect(test2,{Company:"ABC",Employee:"Joe",Hours:5},
{Company:"ABC",Employee:"Joe",Hours:3},
{Company:"ABC",Employee:"Frank",Hours:1},
{Company:"ZXY",Employee:"David",Hours:4},
{Company:"ZXY",Employee:"David",Hours:4},
{Company:"ZXY",Employee:"David",Hours:3},
{Company:"ZXY",Employee:"Mark",Hours:5})

2)gallery1's Items:

GroupBy(test2,"Company","CompanyGroup") 

2)insert gallery2 inside gallery1

Set gallery2's Items:

Distinct(CompanyGroup,Employee)

3)insert a label inside gallery1 to sum the max hours

set the label's Text:

"sum max hours:"&Sum(ForAll(Gallery2.AllItems,LookUp(test2,Employee=Result,Max(Hours))),Value)

4)insert two labels inside gallery2, one to display name, one to display max hours

set label1's Text:

ThisItem.Result

set label2's Text:

LookUp(test2,Employee=ThisItem.Result,Max(Hours))

 

Then the result is the same structure like your listed.10103.PNG

 

 

 

Best regards,

Community Support Team _ Phoebe Liu
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

dyee4614
Level: Powered On

Re: Summarizing Items based on a group

I didn't get it exactly how I wanted it but I was able to figure it out.  The nested gallery was an excellent idea but I needed 3 levels for what I wanted and the system only allowed two.  In the end, I was able to use the group by + sort to get a decent solution.  Here is what I was looking for:

ABC  
 David10
 Joe10
 Steve10

 

Here is how it ended up: 

ABCDavid10
ABCJoe10
ABC Steve10

 

Hope this helps someone. 

 

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 (6,568)