How to average the time between various dates if conditions are met
I'm building a spreadsheet with monthly metrics and having issues creating a formula.
There will be a separate smartsheet with individual events (1 row per event). Each event has ~3 review cycles. Each review cycle includes the date the draft was provided & the date the draft returned.
Formula I'm trying to build:
If the date of notification for the event was within X month, average duration for all review cycles (each review cycle has a column for [date draft X returned] & [date draft X provided]).
I need the formula to go through all rows to find any rows with a date of notification within that month and if it meets that crtieria, to average the 3 review cycles for that event alongside the average of any other review cycles for events that also occurred within that month.
The equation I've tried to use so far is:
=AVERAGEIF({Date of Notification}, MONTH(@cell) = [Start Date]@row, NETDAYS({date draft 1 provided}, {date draft 1 returned})).
This equation only includes 1 review cycle and so far it doesn't work, let alone to add in the remaining 2 review cycles for each event.
Best Answers
-
In that case you can create a row by row average across the review cycles in a single column and then average this single column.
=AVG([First Cycle End]@row - [First Cycle Start]@row, [Second Cycle End]@row - [Second Cycle Start]@row, ……………)
-
Try this while referencing the entire date of notification column:
=AVERAGEIF({Date of Notification}, IFERROR(MONTH(@cell), 0) = MONTH([Start Date]@row), {Phase 1 Review Turnaround})
Answers
-
Are you able to provide some screenshots for context?
Generally speaking though, you would need to output the duration on each row of the source sheet. Then you can average the duration column based on the month of the date column.
-
Here is a screenshot:
For this formula, say I'm building metrics for Feb 2023. So I want the formula to find the rows in red boxes, then to calculate the duration of each review cycle & average the results.
Is there a way to do this without creating helper columns to calculate the duration of each review cycle on the source sheet? For each event, there are ~3 review cycles for each part of the event and events are split into 3 parts. So I already have 18 columns just tracking review cycle dates that drafts are provided & returned. I'd rather not add 6 more helper columns to calculate each duration if it can be avoided.
-
It cannot be done without the helper columns. You can hide helper columns after setting them up though if you are worried about making sure the sheet stays clean.
-
I've added the helper columns, but am still struggling to figure out how to get the formula to work correctly. If the duration helper columns are not adjacent, I'm not sure how to properly select the cells in scope I'm trying to average? or how to get it to average the 3 review cycles for every row with an event in that particular month?
This is what I have so far:
=AVERAGEIF({Date of Notification}, MONTH(@cell) = [Start Date]@row, {Initial Draft Turnaround Duration}, {Rev1 Turnaround Duration}).
-
Are you wanting separate averages between the review cycles or are you wanting just a single overall average?
-
I'm wanting just a single average for all review cycles for all events that had a date of notification within that month
-
In that case you can create a row by row average across the review cycles in a single column and then average this single column.
=AVG([First Cycle End]@row - [First Cycle Start]@row, [Second Cycle End]@row - [Second Cycle Start]@row, ……………)
-
Thanks! That worked for the individual event smartsheet. However, I'm getting an "#INCORRECT ARGUMENT SET" error in my metrics smartsheet when I try to average that column:
=AVERAGEIF({Date of Notification}, MONTH(@cell) = [Start Date]@row, {Phase 1 Review Turnaround})
Where {Date of Notification} is referencing a specific cell from the individual event smartsheet.
When I change the {Date of Notification} to reference the whole Date of Notification column, I get an "#INVALID OPERATION" error.
-
Try this while referencing the entire date of notification column:
=AVERAGEIF({Date of Notification}, IFERROR(MONTH(@cell), 0) = MONTH([Start Date]@row), {Phase 1 Review Turnaround})
-
That worked! I ended up tweaking it a little because I have dates across multiple years, so I needed it to account for both month and year:
=AVERAGEIF({Date of Notification}, AND(IFERROR(MONTH(@cell), 0) = MONTH([Start Date]@row), IFERROR(YEAR(@cell), 0) = YEAR([Start Date]@row)), {Phase 1 Review Turnaround})
Thanks!
-
Happy to help. 👍️
-
I'm trying to figure out how to incorporate the "ISDATE" Function into this formula such that if one of the review cycles is unnecessary and a user enters "N/A" the formula will still calculate correctly.
Currently I have:
=AVG(IF(ISDATE([First Cycle End]@row), [First Cycle End]@row, "") - IF(ISDATE([First Cycle Start]@row), [First Cycle Start]@row, ""), IF(ISDATE([Second Cycle End]@row), [Second Cycle End]@row, ""), - IF(ISDATE([Second Cycle Start]@row), [Second Cycle Start]@row, "") ……………)
But I'm getting a syntax error
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Smartsheet Customer Resources
- 63.7K Get Help
- 406 Global Discussions
- 218 Industry Talk
- 456 Announcements
- 4.7K Ideas & Feature Requests
- 141 Brandfolder
- 136 Just for fun
- 57 Community Job Board
- 459 Show & Tell
- 31 Member Spotlight
- 1 SmartStories
- 297 Events
- 37 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!