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

Announcements

News and Announcements icon
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
    156,064 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 337 Most Valuable Professional

#2
11manish Profile Picture

11manish 173

#3
Valantis Profile Picture

Valantis 86

Last 30 days Overall leaderboard