# How to average the duration between dates if conditions are met

Options
edited 05/16/24

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). The formula I'm trying to build: For all events with a date of notification within X month & year, average duration between 2 dates (start & end date for each event).

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 criteria, to average the duration of that event with any other events that also occurred within that month.

The equation I've tried to use so far is:

=AVERAGEIF({Date of Notification}, AND(IFERROR(MONTH(@cell), 0) = MONTH([Start Date]@row), IFERROR(YEAR(@cell), 0) = YEAR([Start Date]@row)), NETDAYS({Date of Notification}, {Closure Date}))

The {Date of Notification} and {Closure Date} both reference whole columns. Is there a way to do this or do I need to create a helper "Netdays" column within the individual event smartsheet and then use that as my range for AverageIf?

Tags: