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 Platform Community / Forums / Power Apps / Adding a column to a g...
Power Apps
Unanswered

Adding a column to a gallery which is the sum of a filtered list

(0) ShareShare
ReportReport
Posted on by

Hi All, 

 

I have tried numerous times to get this to work and am out of ideas. I have a contact list with a column of "Name" and "OvertimeEligible".  I also have an Overtime Tracking list with columns "Employee Name" and "Hours Worked". 

 

I would like to create a gallery which displays all the OvertimeEligible employees and for each employee, looks up the sum of "Hours Worked" in the Overtime Tracking list. I have been using variations of the following formula in the Gallery "Items" with no success:

 

AddColumns(Filter('Contact List',OvertimeEligible=true),"SumOfHoursWorked",Sum(Filter('Overtime Tracking','Employee Name' = Name),'Hours Worked'))

 

I believe this may have something to do with record scope. When I add a label and use just the sum portion of the above formula, the label displays the proper values. When it is done inside a gallery, it displays a blank value (no error, just no value).

 

Thank you!

Categories:
  • LaurensM Profile Picture
    12,516 Moderator on at

    Hi @yellowjacketjc,

     

    What might be worth trying it explicitly defining the outer loop record scope. Could you give the following code a try:

    AddColumns(
     Filter(
     'Contact List',
     OvertimeEligible //Boolean fields will return true if defined as true, no need for '= true'
     ) As Main,
     "SumOfHoursWorked",
     Sum(
     Filter(
     'Overtime Tracking',
     'Employee Name' = Main.Name
     ),
     'Hours Worked'
     )
    )

     

    When nesting Looping formulas or queries (ForAll, Filter, Addcolumns...) I always explicitly define one of the record scopes. Generally I name the outer scope Main and the inner scope remains implicit.

     

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

    Thanks!

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 312

#3
Mohsin Ali Profile Picture

Mohsin Ali 252

Last 30 days Overall leaderboard