Excel Doc Sum row b where row a in between dates - excel

I have a google spreadsheet having data as below
Date SomeVal
Aug 01, 2013 1
Aug 02, 2013 5
And so on. I want to have another sheet with Monthly grouping as follows(This is what I want in the end but unable to get here)
Month Total
Apr 2013 200
May 2013 300
I tried following but could not get correct result
=SUMIFS(Sheet1!B:B,Sheet1!A:A,ʺ> Aug 1, 2013ʺ) //Returns SUM(B:B) as all dates are above Aug 1 2013
=SUMIFS(Sheet1!B:B,Sheet1!A:A,ʺ< Jun 1, 2014ʺ) //Returns 0 which is wrong
This is what I expected to get
sum for which date > Aug 2013
sum for which date < Jun 2014
My date format is Mon DD, YYYY
Any idea Where I am wrong

This format works for me
Raw Data in Sheet2
(Column A) (Column B)
Date Val
----------- ---------
7/1/2013 1
7/2/2013 2
7/3/2013 3
7/4/2013 4
And so on and so forth up until 2/9/2016 (as long as they are date values you can format them however you want)
Summed Data in Sheet1
(Column A) (Column B)
Month Total
---------- ---------
Jul 2013 496
Aug 2013 1457
Sep 2013 2325
Oct 2013 3348
Nov 2013 4155
So on and so forth for each month that I want, using this formula. Each month is formatted as MMM YYYY, and the date is the first of the month (7/1/2013, 8/1/2013, etc...)
=SUMIFS(Sheet2!$B:$B,Sheet2!$A:$A,">="&Sheet1!$A2,Sheet2!$A:$A,"<"&Sheet1!$A3)
This says
Sum the range in Sheet 2 Column B where:
The date in column A of that row is greater than the first of the month supplied
The date in column A of that row is less than the first of the month afterwards

Related

How to grab the running total of the first day of the month?

I'm trying to write an Excel function to grab the value of the Running Total in rows that are on the first of the month in the Date column. Where there are more rows with the same date, I want to grab the last value. (The dates are in ascending order.)
This is an example of the kind of table I'm using:
Income
Running Total
Date
$1,000.00
$1,000.00
Jun 30, 22
-$60.00
$940.00
Jul 01, 22
-$42.00
$898.00
Jul 20, 22
-$55.00
$843.00
Aug 01, 22
-$200.00
$643.00
Aug 01, 22
-$60.00
$583.00
Aug 19, 22
-$20.00
$563.00
Sep 01, 22
$334.00
$897.00
Sep 10, 22
-$610.00
$287.00
Oct 01, 22
-$50.00
$237.00
Oct 02, 22
I have a formula for calculating the running total and the date is created with the DATE() function.
I'm planing to use the function in a new table on the same sheet. In each row is the running total of the first of that month.
Month
Amount
Jul
Aug
Sep
Oct
The problem is that I'm expecting this table to grow and I don't want to manually search each row. I would like to have a function that goes through the Date column and identifies if it contains the date of the first day of the month, if it does, get the running total.
I have attempted something like this:
=CONCAT("$B",MATCH(”Jul 01, 22”,$C1:$C100,1))
But I don't know how to create the function or whether or not this works.
How can I write a function that grabs the Running Total on the first of the month?
You can use either INDEX() & MATCH() or XLOOKUP()
• Formula used in cell F2
=INDEX($B$2:$B$11,MATCH(DATE(2022,MONTH(E2&1),1),$C$2:$C$11,1))
Or,
• Formula used in cell H2
=XLOOKUP(DATE(2022,MONTH(E2:E5&1),1),C2:C11,B2:B11,,1,-1)
or, can exclude the 5th parameter, of XLOOKUP() as well
• Formula used in cell H2
=XLOOKUP(DATE(2022,MONTH(E2:E5&1),1),C2:C11,B2:B11,,,-1)

Excel: calculate which occurance of a weekday, within the month, from any given date e.g. fifth Friday

I am not very good at Excel. In the NHS (UK) we often schedule activity by looking at the columns on a calendar (e.g. All day theatre list Mondays week 1,3,5). This means on the first Monday, third Monday and if present fifth Monday. Using a printed calendar you can see the columns, for example Mondays in Jan 2023 where there are five.
When planning, it would be great to have a formula that would accept a date, and return the ordinal of the weekday for that month e.g.
Jan 02 2023 = 1
Jan 28 2023 = 4
Jan 29 2023 = 5
Jan 30 2023 = 5
I have searched and found the WEEKNUM function, but this counts rows on the calendar not giving the result I need.
Any help gratefully received
Kind Regards Gavin Holt
This should return those values:
=-INT(-(DAY(YourCellWithTheDate))/7)

How to sum last 3 months by looping through a list in excel?

I have a list of values for each month 1 to 12 in excel. When the quarter ends in December then it should sum the values for the quarter Oct, Nov, and Dec i.e. Month 10, 11, and 12. The current function used is an offset function
=SUM(OFFSET(INDEX($F$999:$F$1008,MATCH(MONTH($B1013),$E$999:$E$1008)),0,0,-3,1)).The formula works well when the starting position is Mar, Jun, Sep, and December. However, assume the quarter ending month is Jan. Then using the above function will only sum values for Jan because above that there are no values 2 months prior.
Desired outcome: If the quarter ends in Jan then it should loop through the list and sum Nov, Dec, and Jan. The goal is to perform a sensitivity analysis because the quarter ending month can be any month, and based on the quarter ending month it will sum up all the values for the quarter.
The list is given below, so if the quarter ends in Feb it should sum (Dec) 10% + (Jan) 3% + (Feb) 6% = 19%
Jan 1 3%
Feb 2 6%
Mar 3 2%
Apr 4 9%
May 5 5%
Jun 6 8%
Jul 7 3.2%
Aug 8 12%
Sep 9 6.5%
Oct 10 5.6%
Nov 11 8%
Dec 12 10%
The trick is to generate a numeric sequence that will match the required months.
Note that, in your table, the month number = the index into the table.
A formula that will generate the required sequence, such that if you the quarter ending month is January (eg month number 1) => {11,12,1} is
Office 365: =SUM(INDEX(monthly,MOD(SEQUENCE(3, ,F2+12-2)-1,12)+1,3))
older versions: =MOD(ROW(INDEX($A:$A,1):INDEX($A:$A,3))+F2+12-4,12)+1
where F2 contains the month number of the ending quarter.
So for O365:
=SUM(INDEX(monthly,MOD(SEQUENCE(3, ,F2+12-2)-1,12)+1,3))
or : =SUM(XLOOKUP(MOD(SEQUENCE(3, ,F2+12-2)-1,12)+1,monthly[monthNum],monthly[perCent]))
where monthly is the name of your table
For earlier versions, try:
=SUM(INDEX(monthly,MOD(ROW(INDEX($A:$A,1):INDEX($A:$A,3))+F2+12-4,12)+1,3))
or even:
=SUM(INDEX(monthly,N(IF(1,MOD(ROW(INDEX($A:$A,1):INDEX($A:$A,3))+F2+12-4,12)))+1,3))
In some earlier versions of Excel, you may need to "confirm" this array-formula by holding down ctrl + shift while hitting enter. If you do this correctly, Excel will place braces {...} around the formula as observed in the formula bar

CountIf column header matches day of week

I have a spreadsheet with a table containing multiple weeks, it has columns and rows like so:
Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun Mon
User 1
User 2
User 3
User 4
A letter "H" will be enters for a users/day when they have booked some holiday, I need to count for each user the number of each days that they have taken as holiday.
I wrote the formula: =COUNTIF(INDEX($N:$NMMATCH("Sun",$N:$NM)),"H")
But this obviously it only returns a count for the first "Sun" column it finds and ignores all the Sundays after.
Does anyone know how this can be accomplished?
If the range for user 1 is N2:NM2 and the headers are in N1:NM1 try this formula to count Suns with "H"
=COUNTIFS(N$1:NM$1,"Sun",N2:NM2,"H")
You can copy that down for all users
Use COUNTIFS:
=COUNTIFS(2:2;"H";$1:$1;"Sun")
Now if you make a small table with Mon up to Sun as headers above it and refer to that for the 4th parameter you can ditch the "Sun"

How do i add year (date) criteria to DSUM?

I have a database that looks like this:
(A1)Client (B1) Date (C1) debts
(A2)1 (B2) Mon 2 november 2008 (C2) 1500$
(A3)2 (B3) Thu 7 february 2008 (C3) 1000$
(A4)3 (B4) Sat 28 March 2009 (C4) 800$
(A5)4 (B5) Mon 16 March 2009 (C5) 1200$
The date format is 24/11/2008.
I have to use DSUM to get the sum of the debts clients had in 2008.
I already did a table that looks like this:
(A7)Client (A7) Date (C7) debts
(A9) 2008
and the function =DSUM(A1:C5,3,A7:C8) but it seems I can't extract the value of 2008 from the date 24/11/2008.
It is generally not a good idea to store dates as text, change your 2008 to 1/1/2008 and format as "YYYY"
To use DSUM to sum entries that fall in a calendar year you will have to define the start and end date, so your filter data will look like this:
Client Date Date
debts =">=1/1/2008" ="<1/1/2009"

Resources