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

Help Simplifying Groupby Collection with Sum

Greetings all,

 

I've been struggling with Aggregating a Grouping from a Collection, thankfully things are starting to click.  However, I'm confident there's a more simplfied & efficient way to build the following:

Collect(colBase,{Description:inpWhat.Text,Location:inpWhere.Text,Cost:inpHowMuch.Text});
ClearCollect(colBaseGroup,GroupBy(colBase,"Description","Location","whatWhere"));
ClearCollect(colBaseSum,AddColumns(colBaseGroup,"Sum of HowMuch",Sum(whatWhere,Cost)))

Thanks very much!

1 ACCEPTED SOLUTION

Accepted Solutions
shailendra74
Level 8

Re: Help Simplifying Groupby Collection with Sum

Hi @cofordpa 

 

2nd & 3rd statements can be combined as follows:

 

ClearCollect(
    colBaseGroup,
    AddColumns(
        GroupBy(
            colBase,
            "Description",
            "Location",
            "whatWhere"
        ),
        "Sum of HowMuch",
        Sum(
            whatWhere,
            Cost
        )
    )
)
2 REPLIES 2
shailendra74
Level 8

Re: Help Simplifying Groupby Collection with Sum

Hi @cofordpa 

 

2nd & 3rd statements can be combined as follows:

 

ClearCollect(
    colBaseGroup,
    AddColumns(
        GroupBy(
            colBase,
            "Description",
            "Location",
            "whatWhere"
        ),
        "Sum of HowMuch",
        Sum(
            whatWhere,
            Cost
        )
    )
)
cofordpa
Level: Powered On

Re: Help Simplifying Groupby Collection with Sum

This is great, thanks!

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

Follow PowerApps on Twitter

Stay Up-to-Date by following PowerApps on Twitter

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

Users Online
Currently online: 82 members 3,948 guests
Please welcome our newest community members: