Counting values within date range

krispatterson

Board Regular
Joined
Apr 28, 2017
Messages
51
Hi guys

Pretty simple one for you lot I'm sure!


Column A - 1000's of dates
Column B - £'s
Column C - £'s

Column D - list of dates (ie Nov 16, Dec 16, Jan 17 etc)



I'm currently using the following formula to count the number of instances of dates within a range:
=COUNTIFS(!$A:$A,">="&D1,!$A:$A,"<"&EDATE(D1,1))

I need to amend it so that my formula:
> looks in Column A and pulls out all dates within a range (so, as the above, only look at date instances in Nov 16)
> if Column A is in Nov 16, the figure from Columns B & C are added together.


Does that make sense? Let me know if it's doable, thanks guys!

Kris
 
I see the problem now, all dates in Workbook 2 have days... while all dates in Workbook 1 don't, so they default to 1, that makes the comparison fail.
 
Upvote 0

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
OK, We have to take only the year and the month, so try this:


ABCDEF
104/11/201615 01/11/2016100
210/11/2016145 01/12/20167
315/11/2016816
414/11/2016410
501/12/201661
622/11/201646

<colgroup><col><col><col span="2"><col><col><col></colgroup><tbody>
</tbody>


F1:
=SUMPRODUCT((YEAR($A$1:$A$5000)&MONTH($A$1:$A$5000)=YEAR(E1)&MONTH(E1))*$B$1:$C$5000))

<tbody>
</tbody>
 
Upvote 0
OK, We have to take only the year and the month, so try this:


ABCDEF
104/11/20161501/11/2016100
210/11/201614501/12/20167
315/11/2016816
414/11/2016410
501/12/201661
622/11/201646

<tbody>
</tbody>


F1:
=SUMPRODUCT((YEAR($A$1:$A$5000)&MONTH($A$1:$A$5000)=YEAR(E1)&MONTH(E1))*$B$1:$C$5000))

<tbody>
</tbody>




Woohoo!! Finally got there... After much frustration etc as to why it was failing, it was because there was 3 instances of non-numerical data in Column B! So, I was getting a #VALUE error... Eventually found the rouge data and have amended, it now works! Thank you so much for all your help people...
 
Upvote 0
OK, so one follow-up question.

I now want to filter that data down so it only adds up based on a range of names.

So Leo, from your example below, table is actually like this:


ABCDEFG
104/11/201615Chris01/11/201610030
210/11/2016145Bob01/12/20167
315/11/2016816Bob
414/11/2016410Chris
501/12/201661Jack
622/11/201646Chris

<tbody>
</tbody>



Original formula is =SUMPRODUCT((YEAR($A$1:$A$5000)&MONTH($A$1:$A$5000)=YEAR(E1)&MONTH(E1))*$B$1:$C$5000))

This original counts the total amount of numbers.

I now need it to also look at Column D and only count the values if the name is specified. I've done this in other places by adding this onto the end: ,!$D:$D,"chris" , but that hasn't worked this time!

My full, not working formula in G1 reads =SUMPRODUCT((YEAR($A$1:$A$5000)&MONTH($A$1:$A$5000)=YEAR(E1)&MONTH(E1))*$B$1:$C$5000,$D:$D,"chris")


i get a #VALUE! error - does that just mean I need to find the rogue data again?? Or have I missed something with that formula?

Thanks :)
 
Upvote 0
it's sumproduct (hit F1 for info)
add another product:
*(D1:D5000="Chris")
 
Upvote 0
it's sumproduct (hit F1 for info)
add another product:
*(D1:D5000="Chris")


Thanks Repush - I thought that would be nice'n'simple, but it's not working.

formula now is =SUMPRODUCT((YEAR($A$1:$A$5000)&MONTH($A$1:$A$5000)=YEAR(E1)&MONTH(E1))*$B$1:$C$5000)*(D1:D5000="Chris")

but that gives me the result as without *(D1:D5000="Chris")


Am I being thick??
 
Upvote 0
just a ")"
=SUMPRODUCT((YEAR($A$1:$A$5000)&MONTH($A$1:$A$5000)=YEAR(E1)&MONTH(E1))*$B$1:$C$5000 *(D1:D5000="Chris")
)
 
Upvote 0
Try reversing the last 2 criteria..
Excel Workbook
ABCDEF
104/11/201615Chris01/11/201630
210/11/2016145Bob01/12/2016
315/11/2016816Bob
414/11/2016410Chris
501/12/201661Jack
622/11/201646Chris
Sheet1
Excel 2010
Cell Formulas
RangeFormula
F1=SUMPRODUCT((YEAR($A$1:$A$5000)&MONTH($A$1:$A$5000)=YEAR(E1)&MONTH(E1))*(D1:D5000="Chris")*$B$1:$C$5000)
 
Upvote 0
it's the misplaced ) . . in a product the order is irrelevant --> 1 x 2 x 3 = 1 x 3 x 2
NB all product need to be inside the sumproduct parentheses
 
Last edited:
Upvote 0
Try reversing the last 2 criteria..

Sheet1
ABCDEF
104/11/201615Chris01/11/201630
210/11/2016145Bob01/12/2016
315/11/2016816Bob
414/11/2016410Chris
501/12/201661Jack
622/11/201646Chris

<thead>
</thead><tbody>
</tbody>
Excel 2010

Worksheet Formulas
CellFormula
F1=SUMPRODUCT((YEAR($A$1:$A$5000)&MONTH($A$1:$A$5000)=YEAR(E1)&MONTH(E1))*(D1:D5000="Chris")*$B$1:$C$5000)

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>




IT'S ALIVE!!!

Mark, thank you - you've come in last minute and saved the day! :)


Thanks as well Repush, much appreciated!
 
Upvote 0

Forum statistics

Threads
1,215,506
Messages
6,125,193
Members
449,213
Latest member
Kirbito

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