Average of Count of Positive Values in a Row - with Gaps

cena1987

New Member
Joined
Jun 12, 2015
Messages
15
Hi all

If I want to find the average of the count totals of consecutive positive values in a row, with gaps of zeros, what formula could I use? An example would be:

1 1 1 1 2 2 2 3 1 1 0 0 0 0 0 0 0 1 2 5 3 3 2

There are two consecutive rows of positive values within the row. The first is 10 values long, the second is 6 numbers long. I'd therefore like the answer to be 8 (10 + 6 / 2).

Any help would be much appreciated.

Thanks

Tom
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Assuming numbers in A2:W2 try

Array formula
=SUM(FREQUENCY(IF(A2:W2>0,COLUMN(A2:W2)),IF(A2:W2=0,COLUMN(A2:W2))))/SUM(IF(FREQUENCY(IF(A2:W2>0,COLUMN(A2:W2)),IF(A2:W2=0,COLUMN(A2:W2))),1))
confirmed with Ctrl+Shift+Enter, not just Enter

M.
 
Upvote 0
Alternative, also with CSE:

=AVERAGE(IFERROR(1/(1/(FREQUENCY(IF(A2:W2,COLUMN(A2:W2)),IF(A2:W2=0,COLUMN(A2:W2))))),""))

Regards
 
Upvote 0
Wait, I think we can use something even simpler (and no CSE).

Assuming X2 is unoccupied:

=COUNTIF(A2:W2,">0")/SUM(COUNTIFS(A2:W2,">0",B2:X2,{0,""}))

Regards
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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