I have a large spreadsheet and I am struggling to get an average, no formula I have used thus far from google or otherwise, has worked.
The average is an average of time, in particular, hours between a start and end time, converted into days.
- In column E9:E1833, I have start time as dd/mm/yyy hh:mm
- In column J9:J1833, I have the time in days, from start to finish as [h]:mm (some are empty)
- I have an auto filter setup to change with job type / area / status etc, and the result needs to change as data is filtered.
The following formula works, but does not recalculate:
The following formula works, but gives an incorrect result:
I have tried Offset, with similar results, and many of the “off-the-shelf” solutions produces
#Value or fail to allow the entry altogether.
Any help would be much appreciated, preferably not in VBA, as I don’t want to be lumbered with this spreadsheet forever. Thanks in advance.
Since you are going to be filtering, and want the result to change as you filter, just use the
EDIT: Animation added in response to question
The values in the Values column can be times, although you may have to format the result of the
AGGREGATE function (cell/numberformat) to show the result as
Note: GIF will play twice. To repeat, refresh the page
The following formula seems to work.
SUBTOTAL(9,OFFSET part of the function returns an array where filtered numbers are 0, and visible numbers return their values. If you just averaged that array, you would get the wrong number because you would be averaging all those zeros. So the
IF statement just creates an array that returns a
FALSE for zero, which is not averaged.
An additional caution that gave me a headache as I was playing around, was you are also filtering on
MONTH()=1. The issue with that is, blank cells return a January date, which means they will not be filtered by