Average n numbers after the first not equal to zero

omerfri

New Member
Joined
Apr 8, 2019
Messages
1
Hi,
I need to average the first n (let's say 3) numbers in a column, from the first one that is not equal to zero.
For example:
[TABLE="width: 192"]
<tbody>[TR]
[TD="width: 64, align: right"]1[/TD]
[TD="width: 64, align: right"]5[/TD]
[TD="width: 64, align: right"]2[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]3[/TD]
[/TR]
</tbody>[/TABLE]

In the left column, checking from down up, first there is a zero, and the average of the following 3 numbers is 2, so the answer is 2.
In the center column there is a zero, and then another zero that the formula need to ignore. The average of the three following is 5, so that's the answer. The answer for the right column is 3.

Please anybody can help me with a formula?+

EDIT:
Just one thing - i didnt mention - the checking of a non zero number is from down to up (from the bottom of the list).
Thanks again.
 
Last edited by a moderator:

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Hi,

say you data is located in range A2:C6

You could list the letters A B C in cells E1, F1, G1

Then in cell E2 you could test following formula :

Code:
=AVERAGE(INDIRECT(E1&IF(ISERROR(MATCH(0,A1:A6,0)-1),MATCH(1E+30,A:A),MATCH(0,A1:A6,0)-1)-2&":"&E1&IF(ISERROR(MATCH(0,A1:A6,0)-1),MATCH(1E+30,A:A),MATCH(0,A1:A6,0)-1)))

And copy it to both B2 and C2 ...

Hope this will help
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top