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

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
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...


[TABLE="width: 435"]
<tbody>[TR]
[TD="class: xl67, width: 87, align: right"]01-2015[/TD]
[TD="class: xl66, width: 87, align: right"]0[/TD]
[TD="class: xl66, width: 87, align: right"]0[/TD]
[TD="class: xl66, width: 87, align: right"]0[/TD]
[TD="class: xl66, width: 87, align: right"]0.6[/TD]
[/TR]
[TR]
[TD="class: xl67, align: right"]02-2015[/TD]
[TD="class: xl66, align: right"]0[/TD]
[TD="class: xl66, align: right"]0[/TD]
[TD="class: xl66, align: right"]0[/TD]
[TD="class: xl66, align: right"]0.6[/TD]
[/TR]
[TR]
[TD="class: xl68, align: right"]03-2015[/TD]
[TD="class: xl69, align: right"]4.59020672[/TD]
[TD="class: xl66, align: right"]251.971064[/TD]
[TD="class: xl70, align: right"]9[/TD]
[TD="class: xl71, align: right"]0.6[/TD]
[/TR]
[TR]
[TD="class: xl67, align: right"]04-2015[/TD]
[TD="class: xl66, align: right"]3.36240616[/TD]
[TD="class: xl66, align: right"]106.422569[/TD]
[TD="class: xl66, align: right"]86[/TD]
[TD="class: xl66, align: right"]0.8[/TD]
[/TR]
[TR]
[TD="class: xl67, align: right"]05-2015[/TD]
[TD="class: xl66, align: right"]4.81086566[/TD]
[TD="class: xl66, align: right"]205.664124[/TD]
[TD="class: xl66, align: right"]315[/TD]
[TD="class: xl66, align: right"]1[/TD]
[/TR]
[TR]
[TD="class: xl67, align: right"]06-2015[/TD]
[TD="class: xl66, align: right"]1.73619817[/TD]
[TD="class: xl66, align: right"]49.2706227[/TD]
[TD="class: xl66, align: right"]17[/TD]
[TD="class: xl66, align: right"]1.2[/TD]
[/TR]
[TR]
[TD="class: xl67, align: right"]07-2015[/TD]
[TD="class: xl66, align: right"]3.4600896[/TD]
[TD="class: xl66, align: right"]154.202966[/TD]
[TD="class: xl66, align: right"]11[/TD]
[TD="class: xl66, align: right"]1.5[/TD]
[/TR]
[TR]
[TD="class: xl67, align: right"]08-2015[/TD]
[TD="class: xl66, align: right"]0.73493376[/TD]
[TD="class: xl66, align: right"]75.8961229[/TD]
[TD="class: xl66, align: right"]6[/TD]
[TD="class: xl66, align: right"]1.8[/TD]
[/TR]
[TR]
[TD="class: xl67, align: right"]09-2015[/TD]
[TD="class: xl66, align: right"]4.8022825[/TD]
[TD="class: xl66, align: right"]50.2926116[/TD]
[TD="class: xl66, align: right"]5[/TD]
[TD="class: xl66, align: right"]2.1[/TD]
[/TR]
[TR]
[TD="class: xl67, align: right"]10-2015[/TD]
[TD="class: xl66, align: right"]3.56508014[/TD]
[TD="class: xl66, align: right"]113.648239[/TD]
[TD="class: xl66, align: right"]21[/TD]
[TD="class: xl66, align: right"]2.4[/TD]
[/TR]
[TR]
[TD="class: xl67, align: right"]11-2015[/TD]
[TD="class: xl66, align: right"]10.8861393[/TD]
[TD="class: xl66, align: right"]303.44733[/TD]
[TD="class: xl66, align: right"]60[/TD]
[TD="class: xl66, align: right"]2.5[/TD]
[/TR]
[TR]
[TD="class: xl67, align: right"]12-2015[/TD]
[TD="class: xl66, align: right"]5.40441557[/TD]
[TD="class: xl66, align: right"]224.030724[/TD]
[TD="class: xl66, align: right"]27[/TD]
[TD="class: xl66, align: right"]2.6[/TD]
[/TR]
[TR]
[TD="class: xl67, align: right"]01-2016[/TD]
[TD="class: xl66, align: right"]0[/TD]
[TD="class: xl66, align: right"]0[/TD]
[TD="class: xl66, align: right"]0[/TD]
[TD="class: xl66, align: right"]2.5[/TD]
[/TR]
[TR]
[TD="class: xl67, align: right"]02-2016[/TD]
[TD="class: xl66, align: right"]3.25087488[/TD]
[TD="class: xl66, align: right"]27.4323336[/TD]
[TD="class: xl66, align: right"]1[/TD]
[TD="class: xl66, align: right"]2.2[/TD]
[/TR]
[TR]
[TD="class: xl68, align: right"]03-2016[/TD]
[TD="class: xl69, align: right"]3.8185344[/TD]
[TD="class: xl66, align: right"]205.742502[/TD]
[TD="class: xl70, align: right"]22[/TD]
[TD="class: xl71, align: right"]1.7[/TD]
[/TR]
[TR]
[TD="class: xl67, align: right"]04-2016[/TD]
[TD="class: xl66, align: right"]4.91242443[/TD]
[TD="class: xl66, align: right"]303.517583[/TD]
[TD="class: xl66, align: right"]82[/TD]
[TD="class: xl66, align: right"]1[/TD]
[/TR]
[TR]
[TD="class: xl67, align: right"]05-2016[/TD]
[TD="class: xl66, align: right"]4.05624659[/TD]
[TD="class: xl66, align: right"]216.618883[/TD]
[TD="class: xl66, align: right"]161[/TD]
[TD="class: xl66, align: right"]0.5[/TD]
[/TR]
</tbody>[/TABLE]



=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,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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