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 Apps
Answered

Summing of values

(1) ShareShare
ReportReport
Posted on by 205
Hi all, I'm trying to do the following of grouping by Dept and summing up the non-empty values in the remaining columns,
So far this is what I have and while it works, it is really inefficient especially as the number of remaining columns grows so it would be great if it could be optimized. Any help is much appreciated!
ClearCollect(deptList, {Dept: "A"}); 
Collect(deptList, {Dept: "B"}); 

ClearCollect(
    testDB0,
    AddColumns(
        GroupBy(
            Filter(
                'Driving Permits',
                'EP 1' <> ""
            ),
            Dept,
            Grouped
        ),
        Count,
        CountRows(Grouped)
    )
);
ClearCollect(testDB1, AddColumns(deptList,'EP 1', LookUp(testDB0,testDB0[@DEPT]=deptList[@Dept],Count)));

ClearCollect(
    testDB2,
    AddColumns(
        GroupBy(
            Filter(
                'Driving Permits',
                'EP 2' <> ""
            ),
            Dept,
            Grouped
        ),
        'EP2',
        CountRows(Grouped)
    )
);

ClearCollect(
    testDB3,
    AddColumns(
        GroupBy(
            Filter(
                'Driving Permits',
                'EP 3' <> ""
            ),
            Dept,
            Grouped
        ),
        'EP3',
        CountRows(Grouped)
    )
);


ClearCollect(finalDB, AddColumns(testDB1,EP2, LookUp(testDB2,testDB2[@DEPT]=testDB1[@Dept],'EP2')));
ClearCollect(finalDB1, AddColumns(finalDB,EP3, LookUp(testDB3,finalDB[@Dept]=testDB3[@DEPT],'EP3')));
 
Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    153,084 Most Valuable Professional on at
    Hi  ccqn
    Probably something like this
    ClearCollect(
       FinalDB,
       AddColumns(
          GroupBy(
             'Driving Permits',
              Dept,
              Grouped
          ),
          EP1,
          CountRows(
             Filter(
                Grouped,
                EP1 > 0
             )
          ),
          EP2,
            CountRows(
             Filter(
                Grouped,
                EP2 > 0
             )
          ),
          EP3,
            CountRows(
             Filter(
                Grouped,
                EP3 > 0
             )
          )
       )
    )
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee

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 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard