Averaging Data Every 20 Seconds

Geijer85

New Member
Joined
Jun 16, 2013
Messages
6
I'm in great need of formula to save me an extreme amount of time and angst. I am attempting to average blood vessel dilation every 20 seconds. I have seconds recorded in one column and diameter in another column. The issue I'm having is that time is not recorded consistently.


Time (sec)Percent Dilation
0
1.016
2.370.678
4.4380.339
4.8751.356
6.9061.016
12.1561.355
13.3440.678
14.016-1.017
14.4221.102
17.563-0.399
18.0631.356
19.2791.017
20.8281.356
24.5631.011
29.5631.069
30.3751.016
31.1720
31.9380.677
36.4410.998
39.981.110
41.3530.976
43.5471.359
44.1121.234

<tbody>
</tbody>

Please, please help.

Thank you.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Code:
       ---A---- ---B---- --C--
   1   Time [s] Dilation  Avg 
   2      0.000    1.016      
   3      2.370    0.678      
   4      4.438    0.339      
   5      4.875    1.356      
   6      6.906    1.016      
   7     12.156    1.355 0.736
   8     13.344    0.678 0.742
   9     14.016   -1.017 0.742
  10     14.422    1.102 0.742
  11     17.563   -0.399 0.718
  12     18.063    1.356 0.718
  13     19.279    1.017 0.718
  14     20.828    1.356 0.777
  15     24.563    1.011 0.789
  16     29.563    1.069 0.875
  17     30.375    1.016 0.905
  18     31.172    0.000 0.840
  19     31.938    0.677 0.857
  20     36.441    0.998 0.938
  21     39.980    1.110 0.921
  22     41.353    0.976 1.059
  23     43.547    1.359 1.135
  24     44.112    1.234 1.135

The formula in C2 and copied down is

Code:
=IF(A2<10, "", 
   SUMIFS($B$2:$B$24, $A$2:$A$24, ">=" & A2-10, $A$2:$A$24, "<=" & A2+10) / 
   COUNTIFS(          $A$2:$A$24, ">=" & A2-10, $A$2:$A$24, "<=" & A2+10))
 
Upvote 0
Thank you, shg. However, that formula does not seem to be producing the information I am looking for. I would like column C to only produce the average dilation of every 20 seconds. So C1 would be the average dilation of seconds 0-19.99, C2 would be the average dilation of seconds 20-39.99, etc. Is there a way to produce such results?

Again, thank you.
 
Upvote 0
Welcome to the MrExcel board!

Does this do what you want?
Both formulas copied down. Adjust the ranges in the column E formula to suit the size of your data.

Excel Workbook
ABCDE
1Time (sec)Percent DilationStart Time (sec)Duration (sec)Average
201.0160200.708083333
32.370.678200.904625
44.4380.339401.189666667
54.8751.356
66.9061.016
712.1561.355
813.3440.678
914.016-1.017
1014.4221.102
1117.563-0.399
1218.0631.356
1319.2791.017
1420.8281.356
1524.5631.011
1629.5631.069
1730.3751.016
1831.1720
1931.9380.677
2036.4410.998
2139.981.11
2241.3530.976
2343.5471.359
2444.1121.234
25
Averages
 
Upvote 0
Hello and thank you, Peter!

I am getting the #DIV/0! result in my cells. Here is the formula I utilized:

=AVERAGEIFS(J$2:J$778,I$2:I$778,">="&L2,I$2:I$778,"<"&L2+M$2)

I'm not sure where I'm going wrong. Any ideas?

Thank you!
 
Upvote 0
Hello and thank you, Peter!

I am getting the #DIV/0! result in my cells. Here is the formula I utilized:

=AVERAGEIFS(J$2:J$778,I$2:I$778,">="&L2,I$2:I$778,"<"&L2+M$2)

I'm not sure where I'm going wrong. Any ideas?

Thank you!
I would expect to get that error if there are no Dilation figures for a time range, and we can deal with that if required.
However, if you are getting the error in all cells then possibly one or both your columns are Text, not Numbers.

In vacant cells, what do these formulas return?
=ISNUMBER(I2)
=ISNUMBER(J2)
 
Upvote 0
I would expect to get that error if there are no Dilation figures for a time range, and we can deal with that if required.
However, if you are getting the error in all cells then possibly one or both your columns are Text, not Numbers.

In vacant cells, what do these formulas return?
=ISNUMBER(I2)
=ISNUMBER(J2)


All of the cells containing the formula you provided return the same error message. I formatted all cells to be numbers, and when entering =ISNUMBER(J2) or =ISNUMBER(I2) for missing data, the value TRUE was returned.
 
Upvote 0
All of the cells containing the formula you provided return the same error message. I formatted all cells to be numbers, and when entering =ISNUMBER(J2) or =ISNUMBER(I2) for missing data, the value TRUE was returned.
Then I'm not sure what the issue is. Here is my sheet again, rearranged to use the columns you appear to be using. Formulas are not returning errors.

Excel Workbook
IJKLMN
1Time (sec)Percent DilationStart Time (sec)Duration (sec)Average
201.0160200.708083333
32.370.678200.904625
44.4380.339401.189666667
54.8751.356
66.9061.016
712.1561.355
813.3440.678
914.016-1.017
1014.4221.102
1117.563-0.399
1218.0631.356
1319.2791.017
1420.8281.356
1524.5631.011
1629.5631.069
1730.3751.016
1831.1720
1931.9380.677
2036.4410.998
2139.981.11
2241.3530.976
2343.5471.359
2444.1121.234
25
Averages



Can you confirm the layout is correct?

Try starting a new worksheet and manually type in a few rows of data and the formulas. What happens in that sheet?
 
Upvote 0
Then I'm not sure what the issue is. Here is my sheet again, rearranged to use the columns you appear to be using. Formulas are not returning errors.

Averages

*IJKLMN
1Time (sec)Percent Dilation*Start Time (sec)Duration (sec)Average
201.016*0200.708083333
32.370.678*20*0.904625
44.4380.339*40*1.189666667
54.8751.356****
66.9061.016****
712.1561.355****
813.3440.678****
914.016-1.017****
1014.4221.102****
1117.563-0.399****
1218.0631.356****
1319.2791.017****
1420.8281.356****
1524.5631.011****
1629.5631.069****
1730.3751.016****
1831.1720****
1931.9380.677****
2036.4410.998****
2139.981.11****
2241.3530.976****
2343.5471.359****
2444.1121.234****
25******

<colgroup><col style="font-weight:bold; width:30px; "><col style="width:80px;"><col style="width:107px;"><col style="width:26px;"><col style="width:116px;"><col style="width:97px;"><col style="width:97px;"></colgroup><tbody>
</tbody>

Spreadsheet Formulas
CellFormula
N2=AVERAGEIFS(J$2:J$778,I$2:I$778,">="&L2,I$2:I$778,"<"&L2+M$2)
L3=L2+M$2

<tbody>
</tbody>

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4


Can you confirm the layout is correct?

Try starting a new worksheet and manually type in a few rows of data and the formulas. What happens in that sheet?


Everything works when I retype the data. Could it be that the seconds and the diameter are calculated with formulas rather than being typed directly?
 
Upvote 0
I tried copying those columns to a new sheet and pasting the values only and everything works to perfection! Thank you, Peter!
 
Upvote 0

Forum statistics

Threads
1,215,479
Messages
6,125,041
Members
449,206
Latest member
Healthydogs

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