Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building 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')));
 
  • Verified answer
    WarrenBelz Profile Picture
    146,596 Most Valuable Professional on at
    Summing of values
    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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,596 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,928 Most Valuable Professional

Leaderboard