Excel Terms of Service
Assuming you only have positive values ββand zeros, you can average without zeros, for non-contiguous ranges using this syntax
=IFERROR(SUM(L4:L10;L12:L18;L20:L26;L28:L34;L36:L37)/INDEX(FREQUENCY((L4:L10;L12:L18;L20:L26;L28:L34;L36:L37);0);2);"")
The part FREQUENCY
gives you an array of two elements, one of which is the number of zeros and the other is positive values, INDEX
then extracts the second one (the number of positive values), so if you divide the sum by that count, you get the mean excluding the zeros. The function FREQUENCY
(as opposed to AVERAGEIF
) accepts a non-overlapping range argument ("union")
.... but if you can figure out which rows to exclude using values ββin another column, then it's easier with AVERAGEIFS
eg. if on excluded lines, eg. in K11
, K21
, K35
, etc. they all have the value "Total", you can use this version:
=IFERROR(AVERAGEIFS(L4:L37;L4:L37;"<>0";K4:K37;"<>Total");"")
configurable based on exact text, wildcards possible
source to share