cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Delvestio
Level: Powered On

HELP! Need formula for Sum Collection in Filtered Gallery

Hi, I need to build a formula that sums the total of hours recorded into a label. 

 

This label needs to show after the gallery results have been filtered using a drop down list. 

 

The result needs to add up all hours posted to the Case File (e.g. Gadbrook Holdings)

 

As it stands I can get the label to add up ALL time but not to show it filtered based on user selection of the individual Case. 

 

Any help would be very much appreciated. 

 

List = Timesheet

Filter Button = Dropdown1

Label = Label2

Column = Hours

 

Main Screen - Hours.JPG

 

Thanks 

1 ACCEPTED SOLUTION

Accepted Solutions
Power Apps Staff CarlosFigueira
Power Apps Staff

Re: HELP! Need formula for Sum Collection in Filtered Gallery

You will need to sum the filtered version of your Timesheet data source - the Filter expression will be the first argument of the Sum function:

"Total Time Recorded: " &
    Sum(
        Filter(Timesheet, Case.Value = Dropdown1.Selected.Value),
        Hours)

Hope this helps!

View solution in original post

6 REPLIES 6
Power Apps Staff CarlosFigueira
Power Apps Staff

Re: HELP! Need formula for Sum Collection in Filtered Gallery

You can either use the same Filter expression that you have in the gallery in your sum expression:

"Total Time Recorded: " & Sum(Filter(Timesheet, <same conditions as in the gallery>), Hours)

Hope this helps!

Delvestio
Level: Powered On

Re: HELP! Need formula for Sum Collection in Filtered Gallery

Hi @CarlosFigueira , Thanks for reaching out.

 

I tried that and it returned an Invalid Argument?

 

"Total Time Recorded: " & Sum(Timesheet,Filter( Timesheet,Case.Value = Dropdown1.Selected.Value),Hours)

 

 

Delvestio
Level: Powered On

Re: HELP! Need formula for Sum Collection in Filtered Gallery

Error.JPG

Power Apps Staff CarlosFigueira
Power Apps Staff

Re: HELP! Need formula for Sum Collection in Filtered Gallery

You will need to sum the filtered version of your Timesheet data source - the Filter expression will be the first argument of the Sum function:

"Total Time Recorded: " &
    Sum(
        Filter(Timesheet, Case.Value = Dropdown1.Selected.Value),
        Hours)

Hope this helps!

View solution in original post

Super User
Super User

Re: HELP! Need formula for Sum Collection in Filtered Gallery

You could do something as simple as: 

 

Label2 = Sum(Gallery2.AllItems, Hours)

 

If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit(Haman)

Highlighted
Community Support Team
Community Support Team

Re: HELP! Need formula for Sum Collection in Filtered Gallery

Hi @Delvestio ,

Based on the formula you provided, I think there is something wrong with it. I have made a test on my side, please consider modify your formula as below:

"Total Time Recorded: " & 
Sum(
     Filter(Timesheet, Case.Value = Dropdown1.Selected.Value),
     Hours
)

 

In addition, you could also consider take a try with the following formula without Filter formula:

"Total Time Recorded: " & 
Sum(
     Gallery2.AllItems,
     Hours
)

 

Please consider take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (4,320)