Reputation: 11657
Might be complicated, so let me give you some background:
I have a spreadsheet that contains the following data:
For example:
1794: Average Positive Value : .65, Average Negative: -.20
1795: Average Positive Value: .75, Average Negative: -.11
I've tried searching around to figure out how to do this, but I don't know the search terms relevant. Would appreciate some assistance.
Thanks!
Upvotes: 4
Views: 607
Reputation: 1935
A solution without array formulas is to use SUMPRODUCT
.
=SUMPRODUCT(--(H1:H7=K10),--(Q1:Q7>0),Q1:Q7)/SUMPRODUCT(--(H1:H7=K10),--(Q1:Q7>0))
I ripped off Siddharth's example shown below with SUMPRODUCT.
Upvotes: 3
Reputation: 420
You should be able to use SUMIFS/COUNTIFS for this.
for positive values:
=sumifs(Q:Q,H:H,1794,Q:Q,">0")/countifs(H:H,1794,Q:Q,">0")
for negative values:
=sumifs(Q:Q,H:H,1794,Q:Q,"<0")/countifs(H:H,1794,Q:Q,"<0")
Upvotes: 2
Reputation: 149287
Here us a simple way using ARRAY Formulas. Please see SNAPSHOT
=IFERROR(AVERAGE(IF(($H$1:$H$7=K10)*($Q$1:$Q$7>0),$Q$1:$Q$7)),"")
You have to enter this using CTL + SHIFT + ENTER
Upvotes: 5
Reputation: 41236
This could be considered kind of a hack, but you could just use some hidden columns that have a copied IF formula per data point. To illustrate:
Add another column A which has IF(Q > 0, Q, 0) Add another column B which has IF(Q > 0, 1, 0) Add another column C which has IF(Q < 0, Q, 0) Add another column D which has IF(Q < 0, 1, 0)
Then, to determine the averages, you can simply do a SUM(A) / SUM(B) and SUM(C) / SUM(D) respectively, since it would be the total value divided by the number of true occurances.
Upvotes: 0