Averaging numbers once they have been filtered.
Good morning all,
I am working on a report for multiple locations.
I'm currently stuck trying to figure out how to create an average for counts collected between two dates. (Weekly/Monthly)
I've created a filter that will allow me to select the dates I want to look at, but my total averages do not change when I filter my results down to 5 from 20. I still see averages and counts for all data filtered and unfiltered.
Thank you!
-Rob
Best Answer
-
You need a formula to do this. A filter just filters the view presented to the user, it doesn't affect calculations in the sheet. You could do this with either some helper columns to enter your start and end dates, or use a helper sheet for the same thing.
Since the AVERAGEIF formula only lets you use a single criteria, we will need to use COUNTIFS and SUMIFS to do the calculations.
I'm going to call your columns "CollectedDate", "StartDate", "EndDate", and "Amount".
=SUMIFS(Amount:Amount, CollectedDate:CollectedDate, >= StartDate@row, CollectedDate:CollectedDate, <= EndDate@row) / COUNTIFS(CollectedDate:CollectedDate, >= StartDate@row, CollectedDate:CollectedDate, <= EndDate@row)
In English - Add up the values in the Amount column where the CollectedDate is on or after the StartDate on this row and is on or before the EndDate on this row, and then divide that by the count of rows where the CollectedDate is on or after the StartDate on this row and is on or before the EndDate on this row.
Regards,
Jeff Reisman
Link: Smartsheet Functions Help Pages Link: Smartsheet Formula Error Messages
If my answer helped solve your issue, please mark it as accepted so that other users can find it later. Thanks!
Answers
-
You need a formula to do this. A filter just filters the view presented to the user, it doesn't affect calculations in the sheet. You could do this with either some helper columns to enter your start and end dates, or use a helper sheet for the same thing.
Since the AVERAGEIF formula only lets you use a single criteria, we will need to use COUNTIFS and SUMIFS to do the calculations.
I'm going to call your columns "CollectedDate", "StartDate", "EndDate", and "Amount".
=SUMIFS(Amount:Amount, CollectedDate:CollectedDate, >= StartDate@row, CollectedDate:CollectedDate, <= EndDate@row) / COUNTIFS(CollectedDate:CollectedDate, >= StartDate@row, CollectedDate:CollectedDate, <= EndDate@row)
In English - Add up the values in the Amount column where the CollectedDate is on or after the StartDate on this row and is on or before the EndDate on this row, and then divide that by the count of rows where the CollectedDate is on or after the StartDate on this row and is on or before the EndDate on this row.
Regards,
Jeff Reisman
Link: Smartsheet Functions Help Pages Link: Smartsheet Formula Error Messages
If my answer helped solve your issue, please mark it as accepted so that other users can find it later. Thanks!
-
Hi Jeff! and thank you.
right now, I am using a filter to select my before and after dates. would I be able to manipulate what you have done above to work with that?
-
No. As I said, you can't perform calculations based on filter selections. If you want to be able to select start/end dates and find values based on selected rows, this has to be done via a formula.
Regards,
Jeff Reisman
Link: Smartsheet Functions Help Pages Link: Smartsheet Formula Error Messages
If my answer helped solve your issue, please mark it as accepted so that other users can find it later. Thanks!
-
Thanks Jeff,
I was finally able to get this functioning. I'm pretty sure using this formula i can figure out a few other things I'd like to measure.
Much appreciated!
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.8K Get Help
- 437 Global Discussions
- 138 Industry Talk
- 470 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 65 Community Job Board
- 486 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 300 Events
- 36 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!