SUMIF Help

drefiek1

New Member
Joined
May 7, 2018
Messages
5
Hi, I am trying to set up a formula which will sum the numbers in one column that meet the following criteria in two other columns: a particular month (in one adjacent column) and greater than or equal to +0.5 (in a second adjacent column). I've put the following formula in but can't get it to work. =SUMIFS(D2:D697,(SUMPRODUCT(--(MONTH($A$2:$A$697)=1),--($M$2:$M$697>=0.5))))


The range I want to sum based on the adjacent columns is D2:D697, with column A (date column) being January (=1) and also based on column M being greater than or equal to +0.5.






I'm also using the following which works elsewhere in the worksheet perfectly so I thought it would be a simple case of adding the SUMIF at the beginning.... =SUMPRODUCT(--(MONTH($A$2:$A$697)=1),--($M$2:$M$697>=0.5))


Thanks.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Hi drefiek1,

Can you provide a small generic set data that can be tested and what you expect for an answer?

Thanks,

Doug
 
Upvote 0
Hi Doug,

Sorry I am new here and haven't got the faintest idea how to attach data or anything but I've copied A38:E54 below, hope it works...


01-20150000.6
02-20150000.6
03-20154.59020672251.97106490.6
04-20153.36240616106.422569860.8
05-20154.81086566205.6641243151
06-20151.7361981749.2706227171.2
07-20153.4600896154.202966111.5
08-20150.7349337675.896122961.8
09-20154.802282550.292611652.1
10-20153.56508014113.648239212.4
11-201510.8861393303.44733602.5
12-20155.40441557224.030724272.6
01-20160002.5
02-20163.2508748827.432333612.2
03-20163.8185344205.742502221.7
04-20164.91242443303.517583821
05-20164.05624659216.6188831610.5

<tbody>
</tbody>



=SUMPRODUCT(--(MONTH($A$2:$A$73)=3),--($E$2:$E$73>=0.5))
This returns a count of 2 for all Marchs (column A) with +0.5 or above (column E). I've coloured the actual cells calculated in red



Now I want to use the same formula as above ^ but instead of returning a simple count I want it to SUM the values in column D based on the above criteria. So I need another new formula for this.

So for all March values >=0.5, it would return the number 31 (D40+D52). I've coloured these green

Furthermore, I also want to use the same criteria (March and +0.5 or above) but instead of counting (first example) or summing (second example) I want to average the length (column B) for the cells meeting the criteria. SO I need another new formula for this as well.

So for all March values >=0.5, it would return the number 4.20437056 (mean of B40 and B52). I've highlighted these in purple

I want the formulas to be fairly easy to change up where needed, so if I wanted a different month or a different >= value etc.

Thanks in advance and apologies if I've made an easy task of copying data here difficult!
 
Upvote 0
Hi,

G3 formula for SUM of column D with your criteria.
H3 Array formula for AVERAGE of column B with your criteria, to be confirmed by CSE (Control, Shift, Enter), instructions below.
If you prefer Not to use an Array formula, use I3 normally entered alternative for AVERAGE:


Book1
ABCDEFGHI
201-20150000.6SUM of DAVERAGE of B
302-20150000.6314.204370564.20437056
403-20154.590207251.971190.6
504-20153.362406106.4226860.8
605-20154.810866205.66413151
706-20151.73619849.27062171.2
807-20153.46009154.203111.5
908-20150.73493475.8961261.8
1009-20154.80228350.2926152.1
1110-20153.56508113.6482212.4
1211-201510.88614303.4473602.5
1312-20155.404416224.0307272.6
1401-20160002.5
1502-20163.25087527.4323312.2
1603-20163.818534205.7425221.7
1704-20164.912424303.5176821
1805-20164.056247216.61891610.5
Sheet627
Cell Formulas
RangeFormula
G3=SUMPRODUCT((MONTH(A2:A73)=3)*(E2:E73>=0.5)*D2:D73)
I3=SUMPRODUCT((MONTH(A2:A73)=3)*(E2:E73>=0.5)*B2:B73)/SUMPRODUCT((MONTH($A$2:$A$73)=3)*($E$2:$E$73>=0.5))
H3{=AVERAGE(IF(MONTH(A2:A73)=3,IF(E2:E73>=0.5,B2:B73)))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Here is what I came up with and it works on your data as best as I can tell.

I created another "table" to the right of your data. The first column (G) is for Months (1 through 12), the second column (H) is a count of the criteria you specified (Month=first column value and column E >=.5), third column (I) is the Sum of the values in B where the conditions are met, fourth column (J) is the mean of the column B values where the conditions are met. The fourth column is simply the third divided by the second. With all the equations working for one month, I copied them down for the other months. I put the .5 for the E>=.5 in cell L2 so it can be changed and the data all updates.

For the equations...
G2 = 1 (Month 1)
H2 =SUMPRODUCT(--(MONTH($A$1:$A$17)=$G2),--($E$1:$E$17>=$L$2))
I2 =SUMPRODUCT(--(MONTH($A$1:$A$17)=$G2),--($E$1:$E$17>=$L$2),$B$1:$B$17)
J2 = I2/H2 (you might want to add and IFERROR in case of #DIV/0! error)

You can easily add another column to sum the D values that meet your conditions. Copy and paste the values down to get the numbers for all months or set it up however works best for you.

Give it a shot on your test data and see how it works out.

Doug
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,695
Members
448,979
Latest member
DET4492

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