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
 
it's the misplaced ) . . in a product the order is irrelevant

Isn't it strange then that reversing the criteria gives the correct answer of 30 without moving the ) :)
Excel Workbook
ABCDEFG
104/11/201615Chris01/11/201630100
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)
G1=SUMPRODUCT((YEAR($A$1:$A$5000)&MONTH($A$1:$A$5000)=YEAR(E1)&MONTH(E1))*$B$1:$C$5000)*(D1:D5000="Chris")
 
Upvote 0

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Isn't it strange then that reversing the criteria gives the correct answer of 30 without moving the ) :)

Sheet1
ABCDEFG
104/11/201615Chris01/11/201630100
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)
G1=SUMPRODUCT((YEAR($A$1:$A$5000)&MONTH($A$1:$A$5000)=YEAR(E1)&MONTH(E1))*$B$1:$C$5000)*(D1:D5000="Chris")

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

<tbody>
</tbody>



Wish I understood it properly, but as long as it works... Thanks again chaps :D
 
Upvote 0
Wish I understood it properly, but as long as it works... Thanks again chaps :D

Both the formula I posted and the one Repush posted work (and the one Repush posted is technically more correct) :)
 
Upvote 0
Isn't it strange then that reversing the criteria gives the correct answer of 30 without moving the ) :)
'reversing the criteria' was actually moving the criterium inside the sumproduct-parentheses

anyhow . . mr. Patterson is happy :cool:
 
Upvote 0
'reversing the criteria' was actually moving the criterium inside the sumproduct-parentheses

I know, when I responded to the question from the OP I didn't give an explanation as to what it was doing differently and why swapping the criteria worked (probably should have). I just gave a different method to achieve the same result (nasty as it was).

anyhow . . mr. Patterson is happy :cool:

Perfectly agree (and hopefully with your explanation the OP understands a bit more now) :cool:
Have a good day :coffee:
 
Upvote 0
@krispatterson

=COUNTIFS(A:A,">="&D1-DAY(D1)+1,A:A,"<="&EOMONTH(D1,0))

where D1 is a date in November of a ceratin year, say November 2016. Preferably: 1-Nov-2016.
 
Upvote 0
Once again, thanks all... & another follow up, sorry!!


I thought I'd got the hang of SUMPRODUCT, but clearly not...

Chart is as follows:
ABCDEFGHIJ
104/11/201615Chris01/11/201641.130100
210/11/2016145Bob01/12/201640.9
315/11/2016816Bob31
414/11/2016410Chris31.5
501/12/201661Jack10.75
622/11/201646Chris42

<tbody>
</tbody>

From Mark858 below, the formulas I used (amended slightly cos I've moved some values around)...

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

<tbody>
</tbody>


What I want in J1 is a formula that does the same as I1, but:
> also looks at F and if F=4, adds up and averages the figures from G.


So, the outcome of J1 should be 1.1 (G1) + 2 (G6) / 2 = 1.55




I'm just not good enough at Excel to get it to do all these things together!! Always really struggle to 'add' formulas together...

Can you help please? :D Thanks
 
Upvote 0

Forum statistics

Threads
1,215,506
Messages
6,125,189
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