Averaging multiple data sets by the data whilst excluding zeros

devinhr

New Member
Joined
Oct 25, 2016
Messages
5
Hi

I need some help. I have multiple data sets on a given day which I would like to average by day, whilst excluding blanks and zeros. As follows:

7/19/2015
5.26
7/19/2015
6.84
7/19/2015
5.97
7/19/2015
3.39
7/19/2015
3.06
7/19/2015
3.26
7/19/2015
3.34
7/20/2015
1.99
7/20/2015
0.74
7/20/2015
1.64
7/20/2015
1.45
7/20/2015
2.22
7/20/2015
2.31
7/20/2015
2.11
7/20/2015
7/29/2015
0.00
8/7/2015
0.00
8/7/2015
43.00
8/7/2015
35.00
8/7/2015
32.00
8/7/2015
8/7/2015
35.69
8/7/2015
34.25
8/8/2015
33.19
8/8/2015
31.63
8/8/2015
0.00

<tbody>
</tbody>


I would like to use a formula that returns a daily average whilst excluding zeros and blank cells. For example, the daily average for the 19th of July 2015 should be 4.45. I would like to be able to drag and copy this formula across large data sets, resulting in a list of average data sets by day. For example:

7/19/2015 - 4.45
7/20/2015 - 1.78
8/7/2015 - 29.9

etc

Thank you for your help.
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
=SUMPRODUCT(--(S4:S105<>0),S4:S105)/(COUNTA(S4:S105)-COUNTIF(S4:S105,0))

Change S4:S105, to suit your range,

let me know if this works for you, the range can then be made dynamic using offset so you can filter for specific dates etc.
 
Last edited:
Upvote 0
or go for a much simpler method, =AVERAGEIFS(B:B,A:A,A1,B:B,"<>"&0) Where A1 would be replaced with date, or cell reference of the date you wish to average
 
Upvote 0
Peter

The SUMPRODUCT array didn't work, it returned a 5 digit number instead. Also I would prefer to not have to go in and change the data range multiple times in the same array. I have a lot of data to work with and this can be time consuming.

The AVERAGEIFS array worked, but is there a way for me to get excel to spit out a table of averages by day without having to go in and specify a date for every average point (i.e. changing A1)? also, how do I get excel to ignore blanks?

Thanks
 
Upvote 0
Assuming your data start at row 2, put the following formula in cell C2 and copy down:

=IF($A2 < > $A1,IFERROR(AVERAGEIFS($B:$B,$B:$B," < > 0",$A:$A,$A2),0),"")

P.S.: blanks are ignored.
P.S.2: is your average for 8/7 correct?
 
Last edited:
Upvote 0
"<>"&0 means does not equal zero, and will exclude the blanks from the averageif.

A1 will be where you have the date saved, change this to where your first date is and then drag in the direction for your other dates, adding $ depending on whether its up or down,
 
Upvote 0
Thank you.

I tried using the array you gave me but excel corrected it to this:
=IF($B7<$B6,IFERROR(AVERAGEIFS($G:$G,$G:$G," < > 0",$B:$B,$B6),0),"")

It returns a blank cell though.

p.s.
B6 is where the first date cell is located on my spreadsheet
G6 is where the first data cell is for the set of data I am looking to average

I have multiple data sets for the same day across different buckets of data so I have used the following to limit the formula based on the way my data is organized (rows 6 to 45):
=IF($B7<$B6,IFERROR(AVERAGEIFS($G6:$G45,$G6:$G45," < > 0",$B6:$B45,$B6),0),"")

this still returns a blank cell.
 
Upvote 0
Peter

This worked so I now have similar averages by date which I can drag across. What did you mean to say with adding the $?

Thank you Peter.
 
Upvote 0
Row\Col
A​
B​
E​
F​
1​
7/19/2015
5.26
5
avg
2​
7/19/2015
6.84
7/19/2015
4.445714286
3​
7/19/2015
5.97
7/20/2015
1.78
4​
7/19/2015
3.39
7/29/2015
5​
7/19/2015
3.06
8/7/2015
35.988
6​
7/19/2015
3.26
8/8/2015
32.41
7​
7/19/2015
3.34
8​
7/20/2015
1.99
9​
7/20/2015
0.74
10​
7/20/2015
1.64
11​
7/20/2015
1.45
12​
7/20/2015
2.22
13​
7/20/2015
2.31
14​
7/20/2015
2.11
15​
7/20/2015
16​
7/29/2015
0
17​
8/7/2015
0
18​
8/7/2015
43
19​
8/7/2015
35
20​
8/7/2015
32
21​
8/7/2015
22​
8/7/2015
35.69
23​
8/7/2015
34.25
24​
8/8/2015
33.19
25​
8/8/2015
31.63
26​
8/8/2015
0

In E1 just enter:

=SUM(IF(FREQUENCY(A1:A26,A1:A26),1))

In E2 control+shift+enter, not just enter, and copy down:

=IF(ROWS($E$2:E2)<=$E$1,INDEX($A$1:$A$26,SMALL(IF(FREQUENCY(IF(ISNUMBER($A$1:$A$26),MATCH($A$1:$A$26,$A$1:$A$26,0)),ROW($A$1:$A$26)-ROW($A$1)+1),ROW($A$1:$A$26)-ROW($A$1)+1),ROWS($E$2:E2))),"")

In F2 just enter and copy down:

=IF($E2="","",IFERROR(AVERAGEIFS($B$1:$B$26,$B$1:$B$26,">0",$A$1:$A$26,$E2),""))
 
Upvote 0

Forum statistics

Threads
1,216,027
Messages
6,128,374
Members
449,445
Latest member
JJFabEngineering

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