Forum

Notifications
Clear all

Average Excluding Zeros

8 Posts
3 Users
0 Reactions
146 Views
(@benjamip)
Posts: 89
Estimable Member
Topic starter
 

Hi

The following formula finds the average of the selected weeks, but I want the average to exclude weeks that are zero?

=AVERAGE(INDIRECT(ADDRESS(ROW(),MATCH($V$1,$2:$2,0),3,1),1):INDIRECT(ADDRESS(ROW(),MATCH($W$1,$2:$2,0),3,1),1))

Any help greatly appreciated.

Thanks Paul

 
Posted : 03/02/2021 11:08 am
(@mynda)
Posts: 4761
Member Admin
 

What version of Excel are you working with, Paul? Hopefully 365.

If you have 365 for Group 1:

=IFERROR(AVERAGE(FILTER(F257:S257,($F$256:$S$256>=$V$1)*($F$256:$S$256<=$W$1)*F257:S2570)),"")

If you have Excel 2019 or earlier for Group 1:

=IFERROR(SUMPRODUCT(G257:S257*($G$256:$S$256>=$V$1)*($G$256:$S$256<=$W$1)*(G257:S2570))/SUMPRODUCT(($G$256:$S$256>=$V$1)*($G$256:$S$256<=$W$1)*(G257:S2570)),"")

Note: You should avoid using INDIRECT at all costs.

Mynda

 
Posted : 03/02/2021 9:17 pm
(@benjamip)
Posts: 89
Estimable Member
Topic starter
 

Thanks Mynda

I do use 365, Worked perfectly,

Out of interest why not use INDIRECT?

Regards

Paul 

 
Posted : 04/02/2021 9:48 am
(@mynda)
Posts: 4761
Member Admin
 

INDIRECT is a volatile function, which can put enormous strain on Excel's calc engine resulting in slow workbooks. Volatile functions recalculate almost every time anything in your workbook changes, as opposed to only calculating when cells the formula is dependent on change, like regular functions. For that reason I only use it as a last resort, especially if the formula is going to occupy many cells.

 
Posted : 04/02/2021 7:42 pm
(@benjamip)
Posts: 89
Estimable Member
Topic starter
 

Thanks Mynda

 
Posted : 05/02/2021 6:52 am
(@benjamip)
Posts: 89
Estimable Member
Topic starter
 

Hi

Formula worked fine until Week number changes to start with 2, then result is wrong?

I can't work out what has gone wrong< any help greatly appreciated

Thanks

Paul

 
Posted : 04/03/2021 7:46 am
(@debaser)
Posts: 836
Member Moderator
 

In an Alphanumeric comparison, the comparison works left to right, character by character. So W2 is greater than W18 because it compares the 2 to the 1, not to 18. You could simply format your single digit weeks to use a leading 0 - i.e. W01, W02, W03 etc.

 
Posted : 04/03/2021 8:00 am
(@benjamip)
Posts: 89
Estimable Member
Topic starter
 

Thanks Velouria

Works perfectly

Regards

Paul

 
Posted : 05/03/2021 2:53 pm
Share: