web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Help with grouping and...
Power Apps
Unanswered

Help with grouping and summation

(0) ShareShare
ReportReport
Posted on by 24

I'm having a hard time with something that I think should be pretty simple. I have a collection, MergedScores, that looks like this:

ParticipantEmailParticipantNameTotalQuestionPointsTotalEventPoints
a@null.netA A5 
b@null.netB B5 
a@null.netA A 25

 

I'm trying to group the collection by email, sum up their question and event points into a new TotalPoints column so the above would become

ParticipantEmailParticipantNameTotalPoints
a@null.netA A30
b@null.netB B5

 

This is what I think should work, but I just get errors that TotalEventPoints and TotalQuestionPoints aren't recognized.

 

ClearCollect(GroupedScores, 
 AddColumns(
 GroupBy(MergedScores, ParticipantEmail, ParticipantName, GroupedQandE) As myGrouping, 
 TotalPoints, 
 Sum(myGrouping.GroupedQandE, TotalQuestionPoints, TotalEventPoints)
 )
);

 

 

What am I doing wrong? Thanks.

Categories:
I have the same question (0)
  • LaurensM Profile Picture
    12,516 Moderator on at

    Hi @skiingdave😊

     

    When using the sum function to sum a table of numbers, it expects 2 parameters. More than 2 parameters is used to calculate the sum of the individual parameters.

     

    Instead of using a comma between TotalQuestionPoints and TotalEvenPoints, use the addition operator:

    Sum(myGrouping.GroupedQandE, TotalQuestionPoints + TotalEventPoints)

     


    If this solves your question, would you be so kind as to accept it as a solution✔️

    If you liked my solution, please give it a thumbs up👍

     

    Connect with me: LinkedIn | Blog

  • skiingdave Profile Picture
    24 on at

    Thanks, this just gives me a generic "there is an error with the formula. Please make corrections and try again" without underlining anything in red so I'm not sure what the issue is. In any case, I've got the app working - I just had to split each step into a separate line of code, which seems kinda clunky but it's fine.

  • skiingdave Profile Picture
    24 on at

    This is what I wound up doing to get it to work. I had to do it as two separate lines :

     

    // group the two scores tables by user
    ClearCollect(GroupedScores, 
     AddColumns(
     GroupBy(MergedScores, ParticipantEmail, ParticipantName, GroupedQandE) As GroupedTemp, 
     TotalEventPoints, 
     Sum(GroupedTemp.GroupedQandE, TotalEventPoints), 
     TotalQuestionPoints, 
     Sum(GroupedTemp.GroupedQandE, TotalQuestionPoints) 
    ));
    
    // Add a Total Score column that is the sum of question and event Points. Clunky but you have to do the above steps and this one at a time.
    // Also get rid of the grouped subtable column while we're at it, though I don't think it matters much
    ClearCollect(TotalScores, 
     DropColumns(
     AddColumns(GroupedScores, TotalPoints, TotalEventPoints + TotalQuestionPoints), 
     GroupedQandE
     )
    );
  • LaurensM Profile Picture
    12,516 Moderator on at

    Thanks for the additional info @skiingdave. Normally the provided code should do the trick, I have written it out in full below. As a first troubleshooting step, save & reopen the Canvas Editor to see whether it affects the error.

     

    ClearCollect(
     GroupedScores, 
     AddColumns(
     GroupBy(MergedScores, ParticipantEmail, ParticipantName, GroupedQandE) As myGrouping, 
     TotalPoints, 
     Sum(myGrouping.GroupedQandE, TotalQuestionPoints + TotalEventPoints)
     )
    );


    The code above resulted in the following collection:

    LaurensM_0-1717100318837.png


    You could remove the nested table column via a DropColumns function.

     

    Your current workaround will work, but it could be worth retrying the approach above in order to improve performance & reduce the amount of code.


    I hope this helps!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard