Solved

Fiddly Excel count and average calculation

Posted on 2013-05-15
2
308 Views
Last Modified: 2013-05-15
I have list of data (32,000 rows deep) that looks like this:

4/1/2013 0:00      0
4/1/2013 0:01      6590
4/1/2013 0:02      0
4/1/2013 0:03      0
4/1/2013 0:04      0
4/1/2013 0:05      0
4/1/2013 0:06      0
4/1/2013 0:07      0
4/1/2013 0:08      0
4/1/2013 0:09      0
4/1/2013 0:10      0
4/1/2013 0:11      0
4/1/2013 0:12      0
4/1/2013 0:13      0
4/1/2013 0:14      0
4/1/2013 0:15      0
4/1/2013 0:16      0
4/1/2013 0:17      0
4/1/2013 0:18      0
4/1/2013 0:19      13350
4/1/2013 0:20      0
4/1/2013 0:21      0
4/1/2013 0:22      0
4/1/2013 0:23      0
4/1/2013 0:24      0
4/1/2013 0:25      0
4/1/2013 0:26      0
4/1/2013 0:27      0
4/1/2013 0:28      0
4/1/2013 0:29      0
4/1/2013 0:30      0
4/1/2013 0:31      0
4/1/2013 0:32      8640
4/1/2013 0:33      0
4/1/2013 0:34      0
4/1/2013 0:35      0
4/1/2013 0:36      0

Date & time with a flow. The Flow is usually zero.

I need to count the zeros from the first zero up to and including the next non-zero number, then divide the non-zero number and populate the adjacent column with the average flow number since the last non-zero. i.e. there are 18 zeros until 13350, 13 zeros until 8640, Like this:

4/1/2013 0:00      0      
4/1/2013 0:01      6590      
4/1/2013 0:02      0      741.6666667
4/1/2013 0:03      0      741.6666667
4/1/2013 0:04      0      741.6666667
4/1/2013 0:05      0      741.6666667
4/1/2013 0:06      0      741.6666667
4/1/2013 0:07      0      741.6666667
4/1/2013 0:08      0      741.6666667
4/1/2013 0:09      0      741.6666667
4/1/2013 0:10      0      741.6666667
4/1/2013 0:11      0      741.6666667
4/1/2013 0:12      0      741.6666667
4/1/2013 0:13      0      741.6666667
4/1/2013 0:14      0      741.6666667
4/1/2013 0:15      0      741.6666667
4/1/2013 0:16      0      741.6666667
4/1/2013 0:17      0      741.6666667
4/1/2013 0:18      0      741.6666667
4/1/2013 0:19      13350      741.6666667
4/1/2013 0:20      0      664.6153846
4/1/2013 0:21      0      664.6153846
4/1/2013 0:22      0      664.6153846
4/1/2013 0:23      0      664.6153846
4/1/2013 0:24      0      664.6153846
4/1/2013 0:25      0      664.6153846
4/1/2013 0:26      0      664.6153846
4/1/2013 0:27      0      664.6153846
4/1/2013 0:28      0      664.6153846
4/1/2013 0:29      0      664.6153846
4/1/2013 0:30      0      664.6153846
4/1/2013 0:31      0      664.6153846
4/1/2013 0:32      8640      664.6153846
4/1/2013 0:33      0      
4/1/2013 0:34      0      
4/1/2013 0:35      0      
4/1/2013 0:36      0
0
Comment
Question by:hgj1357
2 Comments
 
LVL 50

Accepted Solution

by:
barry houdini earned 500 total points
ID: 39169733
Assuming data in columns A and B try this formula in C3 copied down

=IFERROR(IF(B2>0,INDEX(B3:B$33000,MATCH(TRUE,INDEX(B3:B$33000>0,0),0))/MATCH(TRUE,INDEX(B3:B$33000>0,0),0),C2),"")

see attached

regards, barry
average-across-rows.xlsx
0
 
LVL 2

Author Closing Comment

by:hgj1357
ID: 39169843
Bob's your uncle!  Works like a charm
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My experience with Windows 10 over a one year period and suggestions for smooth operation
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question