Count number of entries that have a date stamp of last week

chive90

New Member
Joined
May 3, 2023
Messages
35
Office Version
  1. 2016
In Sheet2 Column F I have a date in DD/MM/YYYY format.
In Sheet 2 Column G I have the source which is listed as either "A" or "B"

In Sheet1 I have a summary table.
In cell B10 of Sheet1 I would like a count of Sheet2 entries that have last week's date AND have a source of A.
In cell B11 of Sheet1 I would like a count of Sheet2 entries that have last week's date AND have a source of B.

So at the time of writing this (20th October) that would be any that fall between 9th-15th October. This range will change to 16th-22nd October on Monday 23rd October.

I also require a SUM of Sheet2 Column C based on the above criteria (date stamp and source A, date stamp and source B) which will be entered in Sheet1 C10 and C11 respectively
and a SUM of Sheet2 Column D based on the above criteria (date stamp and source A, date stamp and source B) which will be entered in Sheet1 D10 and D11 respectively

I imagine I can use a COUNTIFS for the first requirement and a SUMIFS for the second and third requirements but I am not sure how to add in the date element nor how this impacts the formulas.

Thanks for any help
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Have a look here for how to use a date range criteria for COUNTIFS and SUMIFS formulas:
Of course, with COUINTIFS and SUMIFS, you can add more than two conditions, so entering source criteria to that should be a trivial addition.
 
Upvote 0
Have a look here for how to use a date range criteria for COUNTIFS and SUMIFS formulas:
Of course, with COUINTIFS and SUMIFS, you can add more than two conditions, so entering source criteria to that should be a trivial addition.

Thanks but the dates are constantly moving, they aren't static. It always needs to count the previous week, which, depending on when the file is opened, will be different.
 
Upvote 0
You don't have to hard code the dates - you can reference cells that hold the dates you want to use or use formulas to calculate the dates you want.
 
Upvote 0
If your real issue is how to calculcate the Monday of the previous week, see this thread here: Previous Monday Date
It looks like this formula will return that for you:
Excel Formula:
=TODAY()-WEEKDAY(TODAY())-5
Then, to get the Sunday ending that week, just add 6 to the above value.
 
Upvote 0
Solution
If your real issue is how to calculcate the Monday of the previous week, see this thread here: Previous Monday Date
It looks like this formula will return that for you:
Excel Formula:
=TODAY()-WEEKDAY(TODAY())-5
Then, to get the Sunday ending that week, just add 6 to the above value.

Thanks. I also saw a thread which suggested using the following where TODAY() is in A1:
=A1-WEEKDAY(A1,3)-7 to get last Monday and;
=A1-WEEKDAY(A1,3)-1 to get last Sunday

Can you explain how these differ to your formula?

I managed to use the above in my COUNTIFS formula per your suggestion, by referencing both date cells using ">=" and "<=" and it appears to be working so thank you.
 
Upvote 0
Thanks. I also saw a thread which suggested using the following where TODAY() is in A1:
=A1-WEEKDAY(A1,3)-7 to get last Monday and;
=A1-WEEKDAY(A1,3)-1 to get last Sunday

Can you explain how these differ to your formula?
The formulas can look different by return the same value, due to the different values of the 2nd argument of the WEEKDAY function (see here: WEEKDAY function).
Based on which day of the week you pick for the start of the week, you would subtract a different number of days.
 
Upvote 0

Forum statistics

Threads
1,215,077
Messages
6,122,991
Members
449,094
Latest member
masterms

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