Summing hours between range of dates, looking up to separate table in excel - excel

In cells A1:B6 I have the following info.
Weekday Hours
Monday 5
Tuesday 5
Wednesday 0
Thursday 5
Friday 0
In cells A8:B9 I have a date range, e.g.
From: To:
09/01/19 11/01/19
In cell C9 I want a formula which tells me how many hours are between the from and to dates. Not the total number of hours, but the sum of hours as they appear in the weekday table.
There is a helpful article on exceljet which got me some of the way here., but I got tangled in the array formulas and could not fix it.
The result of the formula should be: 5. ie. there are 5 hours between Wednesday 09/01/2019 and Friday 11/01/2019. (dd/mm/yy)
Any help is gratefully received.

Use SUMIFS:
=SUMPRODUCT(SUMIFS(B:B,A:A,TEXT(ROW(INDEX(XFA:XFA,D2):INDEX(XFA:XFA,E2)),"dddd")))

Related

Excel : Weeknumber within month with criteria

I'm trying to make a formule to calculate the weeknumber within a week but with certain criteria. The week always starts on a monday. But if the thursday of that week is in the next month, then that weeknumber is part of the next month.
[enter image description here][2]
Right now I have the following formula:
=INTEGER((6+DAY(A4+1-WEEKDAY(A4-1)))/7) where A4 is the date.
This already calculates the weeknumber within the month, but not with the criteria of thursday. An extra added criteria is that the weeknumber should start from 6am on monday instead of at midnight. But that I can solve with an extra column to check for that.
Thanks in advance!
Consider working out the week number from the previous week number:
If it is Monday then
If following Thursday goes into the next month, reset to 1
Else increase by 1
Else use same value
So starting with a 1 in E4
=IF(WEEKDAY(A5)=2,IF(MONTH(A5+3)>MONTH(A5-4),1,E4+1),E4)
entered in E5 and copied down.
EDIT
Above works for 2017 but would need slight change to work for 2018 and onwards because month decreases from 12 to 1 across year boundary:
=IF(WEEKDAY(A5)=2,IF(MONTH(A5+3)<>MONTH(A5-4),1,E4+1),E4)
I cant upload a workbook but here is a solution:
Row 2 is headers
Row 3 is empty
B4 going down is the date(01/01/2017 up to 31/12/2017)
C4 =WEEKDAY(B4,2)
D4 =VLOOKUP($C4,$L$3:$M$9,2,0)
E4 =MONTH(B4)
F4 to J4 are empty
F5 =IF(C5=1,F4+1,F4)
G5 =IF(C5=4,11,0)
H5 =IF(MAX(E5:E11)-MIN(E5:E11)<>0,22,0)
I5 =IF(AND(C5=4,SUM(G5:G11)+SUM(H5:H11)>22),I4+1,0)
J5 =IF(H6-H5<0,1,IF(H6=22,J5,IF(OR(C6=1,I6<>0),J5+1,J5)))
L3 to M9 are vlookups
1 Monday
2 Tuesday
3 Wednesday
4 Thursday
5 Friday
6 Saturday
7 Sunday
Does that work ok for you?
In my experience most of those week number questions can be answered with some variation of your original formula - in this case this version should cater for Monday week start with the Thursday determining the month
=INT((6+DAY(B4+4-WEEKDAY(B4-1)))/7)
That works for a date in A4 but assuming you have a date/time in A4 and the week doesn't start until 06:00 on Monday then you can tweak that as follows:
=INT((6+DAY(B4+3.75-WEEKDAY(B4-1.25)))/7)

Excel Formula: Current 12 months

I'm looking for a formula in excel that will give me a current 12 month table. For example this month is April. I want a formula that gives me 12 months back from April in the exact format as show in the table below. For next month it will be May, and 12 months back from may without having to adjust any dates.
Month
5/1/2015
6/1/2015
8/1/2015
9/1/2015
10/1/2015
11/1/2015
12/1/2015
1/1/2016
2/1/2016
3/1/2016
4/1/2016
Thank you
Try this and copy down 11 rows
=EDATE((TODAY()-DAY(TODAY())+1),ROW(A1)-12)
If you number the months in column b starting from b2 =0 to b13=11
And row 1 has headers
A2 formula =EOMONTH(today(),b2-1)+1
A3 formula = EOMONTH(today(),b3-1)+1
Etc.
EOMONTH will give you the last day of any month. So if we start with today() it will give you the last day of the current month, but if we count back 1 month (b2-1). It will give you the last day of last month. So we add 1 day to it and you get the first day of each month.
Hope this helps :)

weekly spend formula in Excel 2007

Can anyone help please?
I have a spreadsheet where A:A contains dates and B:B shows the amount i spent on that day in relation to the date in A:A.
What i would like to do is have C1 show a running total of what i have spent this week.
I am using Excel 2007 and i cannot get my head around this.
I am going round in circles here, i can get =SUMPRODUCT((WEEKDAY(A2:A1000)=5)*(B2:B1000)) which shows how much has been spent on a thursday, justcannot work out how to say for the last week
You can apply the SUMIFS function with the TODAY functio and WEEKDAY function to gain a total of the current week.
'for a Sunday to Saturday week
=SUMIFS(B:B, A:A, ">"&TODAY()-WEEKDAY(TODAY()))
'for a Monnday to Sunday week
=SUMIFS(B:B, A:A, ">"&TODAY()-WEEKDAY(TODAY(), 2))
'for the previous Sunday to Saturday week
=SUMIFS(B:B,A:A, ">"&TODAY()-WEEKDAY(TODAY())-7,A:A, "<="&TODAY()-WEEKDAY(TODAY()))
=SUMIFS(B:B, A:A, ">"&TODAY()-WEEKDAY(TODAY(), 2)-7,A:A, "<="&TODAY()-WEEKDAY(TODAY(), 2))
The total for other 7 day periods can be returned with a little maths.
I've used the SUMIFS function here as the syntax changes between the SUMIF function and SUMIFS. Using SUMIFS in all cases means that you do not have to alter the syntax depending on whether you are using it one condition or multiple conditions.
Make it simpler.
Add a column before the DATE column and call it WEEK
In A2 use (x should be 1 , 2 depending on the system for your country)
=Year(B2)&WeekNum(B2,x)
1 = week start sunday
2 = week start monday
then in D2 use ( and drag it down the column)
=SUMIF(A$2:A2,A2,C$2:C2)

Using index in excel how to get a 6th value from a array

I am trying to get 6th day from the day itself and should repeat for 3 times but I am not able to get the desired output
Column A Column B(Expected output)
Sunday Sunday
Monday Friday
Tuesday Wednesday
Wednesday Monday
Thursday Saturday
Friday Thursday
Saturday Tuesday
Sunday
Wednesday
Monday
Saturday
Thursday
Tuesday
Sunday
Wednesday
Monday
Saturday
Thursday
Tuesday
Sunday
I am using:
=INDEX($E$1:$E$7,6)
and I am getting only Friday and if I do auto fill only Friday is copied to all cells.
Any assistance much appreciated.
If I understand you correctly, you want to show the name of every sixth day from a starting date. There are different approaches to that. The Index() one is a possibility, but not the easiest.
Easier: In the first cell (B1), enter the starting date. Format with custom format "dddd".
In the next cell down use a formula
=B1+5
and format with custom format "dddd". Copy down as far as desired.
OR use
=TEXT($B$1+((ROW()-1)*5),"dddd")
and copy down.
If you want to base this on today's date, you can start in B1 with
=TEXT(TODAY()+((ROW()-1)*5),"dddd")
and copy down.
EDIT: if the cell contents is not about dates and weekdays, but just any text or value, then you can use the Index() approach. For an array with seven values, you want to extract every 6th value, looping through the seven values. That would mean that the values are accessed in the following order:
1
6
4
2
7
5
3
Therfore, you need a formula that delivers this number sequence. This formula, if started in row 1 and copied down, does that:
=(1+((ROW()-1)*5))-((INT((1+((ROW()-1)*5))/7)-IF(MOD((1+((ROW()-1)*5))/7,1),0,1))*7)
Wrap an Index around it and adjust your column references. In B1 and copied down to B21:
=INDEX($A$1:$A$7,(1+((ROW()-1)*5))-((INT((1+((ROW()-1)*5))/7)-IF(MOD((1+((ROW()-1)*5))/7,1),0,1))*7))

In Excel, how to calculate # of days between a date range, counting only specific days of week

I'm trying to get # days between 2 dates, but had to count only days of the week specified per pair of dates in questions.
For example:
Date of operation = 9/1/2013 and 5/16/2014
Days of the Week in operation = Monday, Wednesday, Friday
I want to calculate total number of days in actual operation, given the days in operation per week.
If you have Excel 2010 or later you can use NETWORKDAYS.INTL function which allows you to customise which days are counted, e.g. the following formula will count Mondays, Wednesdays and Fridays between a start date in A2 and an end date in B2 (inclusive) while excluding holiday dates listed in H2:H10
=NETWORKDAYS.INTL(A2,B2,"0101011",H$2:H$10)
The string "0101011" defines the days to include - 0 is included, 1 is excluded - it starts with Monday
In earlier excel versions you can use this formula for the same result
=SUMPRODUCT((WEEKDAY(ROW(INDIRECT(A2&":"&B2)))={2,4,6})*(COUNTIF(H$2:H$10,ROW(INDIRECT(A2&":"&B2)))=0))
where {2,4,6} defines the weekdays to include (1=Sun through to 7=Sat)
The number of days between to dates is just date1 - date2.
One method is to divide the number of days in operation by the number of days in the week. In this case that would be 3/7. In this example, the number of days in operation would be 110.14 days. Below is your example. cell B4 has 1-sep-13, b6 has 16-may-14, both formatted as dates.
B
4 41518
6 41775
8 =B6-B4 Days
9 =B8/7 Weeks
10 =B8*3/7
01-Sep-13
16-May-14
257 Days
36.71 Weeks
110.14
To get more accurate, you would need to know which day of the week, weekday(), the first day in your range was and which day of the week your last day was.

Resources