Calculate based on date sum of hours based on date

psycoperl

Active Member
Joined
Oct 23, 2007
Messages
338
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. MacOS
  3. Web
I have a problem that I am trying to solve. I am working on a Timecard project. I have two sheets: FWS_TimeCard which is the timecard where all the hours that are paid out and recorded; and Allocation_Table which is the source of pay rates and number of available hours.

As we can have a payrate change in the middle of a Fiscal Year, I need to adjust the available hours balance to take into account when the pay rate changes. What I am trying to figure out is how to do the following:
  1. In Allocation_Table!B14 enter Sum of hours used (Columns D & L) for each date in the FWS_TimeCard sheet (Columns C & K) if date is before Fed Work Study Spring Rate Start Date (Allocation_Table!B32), excluding any "CLOSED", "NO FWS" or any Non Numeric values.
  2. In Allocation_Table!B16 enter Sum of hours used (Columns D & L) for each date in the FWS_TimeCard sheet (Columns C & K) if date is on or after Fed Work Study Spring Rate Start Date (Allocation_Table!B32), excluding any "CLOSED", "NO FWS" or any Non Numeric values.
The FWS_TimeCard rows start on Row 17, with the first rows of dates on row 20.

My TimeCard sheet has 27 pay periods that look like the following.
000 BLANK 23-241.xlsx
ABCDEFGHIJKLMNOPQ
211
212Pay Pd 14Start:17-Dec-23End:30-Dec-23FWS Wk Days0
213Week 1Week 2
214DatesFWSDatesFWS
215Sunday17-Dec-23ClosedSunday24-Dec-23Closed
216Monday18-Dec-23Monday25-Dec-23Closed
217Tuesday19-Dec-23Tuesday26-Dec-23
218Wednesday20-Dec-23Wednesday27-Dec-23
219Thursday21-Dec-23Thursday28-Dec-23
220Friday22-Dec-23ClosedFriday29-Dec-23Closed
221Saturday23-Dec-23ClosedSaturday30-Dec-23Closed
222Total Weekly Hours0.00Total Weekly Hours0.00
223Pay Period TotalsFWS0.00
224
225
226
227Pay Pd 15Start:31-Dec-23End:13-Jan-24FWS Wk Days7
228Week 1Week 2
229DatesFWSDatesFWS
230Sunday31-Dec-23ClosedSunday7-Jan-24Closed
231Monday1-Jan-24Monday8-Jan-24
232Tuesday2-Jan-24Tuesday9-Jan-24
233Wednesday3-Jan-24Wednesday10-Jan-24
234Thursday4-Jan-24Thursday11-Jan-24
235Friday5-Jan-24Friday12-Jan-24
236Saturday6-Jan-24ClosedSaturday13-Jan-24Closed
237Total Weekly Hours0.00Total Weekly Hours0.00
238Pay Period TotalsFWS0.00
239
240
FWS_TimeCard
Cell Formulas
RangeFormula
B212,B227B212=IF(B197+1<=27, B197+1, 1)
D212,D227D212=B215
H212,H227H212=K221
N212,N227N212=SUM( IF(OR($C215="CLOSED",$C215="NO FWS"),0,IF(NOW()<=$B215,1,0)), IF(OR($C216="CLOSED",$C216="NO FWS"),0,IF(NOW()<=$B216,1,0)), IF(OR($C217="CLOSED",$C217="NO FWS"),0,IF(NOW()<=$B217,1,0)), IF(OR($C218="CLOSED",$C218="NO FWS"),0,IF(NOW()<=$B218,1,0)), IF(OR($C219="CLOSED",$C219="NO FWS"),0,IF(NOW()<=$B219,1,0)), IF(OR($C220="CLOSED",$C220="NO FWS"),0,IF(NOW()<=$B220,1,0)), IF(OR($C221="CLOSED",$C221="NO FWS"),0,IF(NOW()<=$B221,1,0)), IF(OR($L215="CLOSED",$L215="NO FWS"),0,IF(NOW()<=$K215,1,0)), IF(OR($L216="CLOSED",$L216="NO FWS"),0,IF(NOW()<=$K216,1,0)), IF(OR($L217="CLOSED",$L217="NO FWS"),0,IF(NOW()<=$K217,1,0)), IF(OR($L218="CLOSED",$L218="NO FWS"),0,IF(NOW()<=$K218,1,0)), IF(OR($L219="CLOSED",$L219="NO FWS"),0,IF(NOW()<=$K219,1,0)), IF(OR($L220="CLOSED",$L220="NO FWS"),0,IF(NOW()<=$K220,1,0)), IF(OR($L221="CLOSED",$L221="NO FWS"),0,IF(NOW()<=$K221,1,0)))
B215,B230B215=K206+1
B216:B221,K231:K236,B231:B236,K216:K221B216=B215+1
K215,K230K215=B221+1
C222,L237,C237,L222C222=SUM(C215:C221)
G223,G238G223=SUM(C222,L222)


The Allocation_Table is the following:
000 BLANK 23-241.xlsx
AB
12Federal Work Study Grant$ -
13Fed. Work Study - Sum/Fall - Hourly Rate$ -
14Fed. Work Study - Sum/Fall - Hours Used0.00
15Fed. Work Study - Spring - Hourly Rate$ -
16Fed. Work Study - Sum/Fall - Hours Used0.00
17Federal Work Study Work - Sum/Fall Hrs0
18Federal Work Study Work - Spring Hrs0
Allocation_Table
Cell Formulas
RangeFormula
B16B16=B14*B15
B17:B18B17=IF(B12>0,ROUND((B14)/B15,2),0)

000 BLANK 23-241.xlsx
AB
31Fed. Work Study - Sum/Fall Rate Start Date7/1/2023
32Fed. Work Study - Spring Rate Start Date12/31/2023
33FWS Allocation Period End5/23/2024
Allocation_Table
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
If that is the case how about?:
extending the ranges as needed

SumOfHours.xlsx
AB
14Sum of hours used 17
15Sum of hours used 210
Allocation_Table
Cell Formulas
RangeFormula
B14B14=LET( d,VSTACK(FWS_TimeCard!$B$20:$B$10000,FWS_TimeCard!$K$20:$K$10000), f,VSTACK(FWS_TimeCard!$C$20:$C$10000,FWS_TimeCard!$L$20:$L$10000), res,FILTER(d,IFERROR(ISNUMBER(d)*(d>DATE(2020,1,1)),0)*(d<$B$32)*NOT((f="CLOSED") + (f="NO FWS") + ISNUMBER(f))), COUNTA(res) )
B15B15=LET( d,VSTACK(FWS_TimeCard!$B$20:$B$10000,FWS_TimeCard!$K$20:$K$10000), f,VSTACK(FWS_TimeCard!$C$20:$C$10000,FWS_TimeCard!$L$20:$L$10000), res,FILTER(d,IFERROR(ISNUMBER(d)*(d>DATE(2020,1,1)),0)*(d>=$B$32)*NOT((f="CLOSED") + (f="NO FWS") + ISNUMBER(f))), COUNTA(res) )
 
Upvote 0
If that is the case how about?:
extending the ranges as needed

SumOfHours.xlsx
AB
14Sum of hours used 17
15Sum of hours used 210
Allocation_Table
Cell Formulas
RangeFormula
B14B14=LET( d,VSTACK(FWS_TimeCard!$B$20:$B$10000,FWS_TimeCard!$K$20:$K$10000), f,VSTACK(FWS_TimeCard!$C$20:$C$10000,FWS_TimeCard!$L$20:$L$10000), res,FILTER(d,IFERROR(ISNUMBER(d)*(d>DATE(2020,1,1)),0)*(d<$B$32)*NOT((f="CLOSED") + (f="NO FWS") + ISNUMBER(f))), COUNTA(res) )
B15B15=LET( d,VSTACK(FWS_TimeCard!$B$20:$B$10000,FWS_TimeCard!$K$20:$K$10000), f,VSTACK(FWS_TimeCard!$C$20:$C$10000,FWS_TimeCard!$L$20:$L$10000), res,FILTER(d,IFERROR(ISNUMBER(d)*(d>DATE(2020,1,1)),0)*(d>=$B$32)*NOT((f="CLOSED") + (f="NO FWS") + ISNUMBER(f))), COUNTA(res) )

I am getting unexpected results.
Using this formula in Allocation_Table!B14
Excel Formula:
=LET(
d,VSTACK(FWS_TimeCard!$B$20:$B$26,FWS_TimeCard!$K$20:$K$26),
f,VSTACK(FWS_TimeCard!$C$20:$C$26,FWS_TimeCard!$L$20:$L$26),
res,FILTER(d,IFERROR(ISNUMBER(d)*(d>=$B$30),0)*(d<$B$32)*NOT((f="CLOSED") + (f="NO FWS") + ISNUMBER(f))),
COUNTA(res)
)

000 BLANK 23-241.xlsx
AB
14Fed. Work Study - Fall - Hours Used1.00
Allocation_Table
Cell Formulas
RangeFormula
B14B14=LET( d,VSTACK(FWS_TimeCard!$B$20:$B$26,FWS_TimeCard!$K$20:$K$26), f,VSTACK(FWS_TimeCard!$C$20:$C$26,FWS_TimeCard!$L$20:$L$26), res,FILTER(d,IFERROR(ISNUMBER(d)*(d>=$B$30),0)*(d<$B$32)*NOT((f="CLOSED") + (f="NO FWS") + ISNUMBER(f))), COUNTA(res) )

000 BLANK 23-241.xlsx
AB
30FY Start7/1/2023
31CA Allocation Period End6/30/2024
32Fed. Work Study - Sum/Fall Rate Start Date7/1/2023
33Fed. Work Study - Spring Rate Start Date12/31/2023
34FWS Allocation Period End5/23/2024
Allocation_Table



When I am working with this sample of data (Range is rows 20 to 26, which is period 1) using the formula I get a return of 1. The expected result is 0 as the dates as all the dates except 1 are before the FY Start (B30) and that day is listed as "Closed"
Pay Pd 1Start:18-Jun-23End:1-Jul-23FWS Wk Days0
Week 1Week 2
DatesFWSDatesFWS
Sunday18-Jun-23ClosedSunday25-Jun-23Closed
Monday19-Jun-23Monday26-Jun-230.00
Tuesday20-Jun-23Tuesday27-Jun-230.00
Wednesday21-Jun-23Wednesday28-Jun-230.00
Thursday22-Jun-23Thursday29-Jun-230.00
Friday23-Jun-23ClosedFriday30-Jun-23Closed
Saturday24-Jun-23ClosedSaturday1-Jul-23Closed
Total Weekly Hours0.00Total Weekly Hours0.00
Pay Period TotalsFWS0.00


And when using the range of rows 35 to 41, expected result is 5.00 however receiving 1
Pay Pd 2Start:2-Jul-23End:15-Jul-23FWS Wk Days0
Week 1Week 2
DatesFWSDatesFWS
Sunday2-Jul-23ClosedSunday9-Jul-23Closed
Monday3-Jul-23ClosedMonday10-Jul-23
Tuesday4-Jul-23Tuesday11-Jul-23
Wednesday5-Jul-235.00Wednesday12-Jul-23
Thursday6-Jul-23Thursday13-Jul-23
Friday7-Jul-23Friday14-Jul-23Closed
Saturday8-Jul-23ClosedSaturday15-Jul-23Closed
Total Weekly Hours5.00Total Weekly Hours0.00
Pay Period TotalsFWS5.00
 
Upvote 0
When I am working with this sample of data (Range is rows 20 to 26, which is period 1) using the formula I get a return of 1. The expected result is 0 as the dates as all the dates except 1 are before the FY Start (B30) and that day is listed as "Closed"

Where did cell FY Start (B30) come from?
In your original post you said dates before and after Fed Work Study Spring Rate Start Date (Allocation_Table!B32)

1704299408627.png


Which is 12/31/2023
 
Upvote 0
In your original formula you had "FILTER(d,IFERROR(ISNUMBER(d)*(d>DATE(2020,1,1)),0", I just put the lowest date to use as a value in the Allocation Table.
 
Upvote 0
There was an error when filter was returning 0 item.
this should correct this:

SumOfHours.xlsx
AB
14Sum of hours used 14
15Sum of hours used 20
Allocation_Table
Cell Formulas
RangeFormula
B14B14=LET( d,VSTACK(FWS_TimeCard!$B$20:$B$10000,FWS_TimeCard!$K$20:$K$10000), f,VSTACK(FWS_TimeCard!$C$20:$C$10000,FWS_TimeCard!$L$20:$L$10000), res,FILTER(d,IFERROR(ISNUMBER(d)*(d>DATE(2020,1,1)),0)*(d<$B$32)*NOT((f="CLOSED") + (f="NO FWS") + ISNUMBER(f))), IF(SUM(ISERROR(res)),0,COUNTA(res)) )
B15B15=LET( d,VSTACK(FWS_TimeCard!$B$20:$B$10000,FWS_TimeCard!$K$20:$K$10000), f,VSTACK(FWS_TimeCard!$C$20:$C$10000,FWS_TimeCard!$L$20:$L$10000), res,FILTER(d,IFERROR(ISNUMBER(d)*(d>DATE(2020,1,1)),0)*(d>=$B$32)*NOT((f="CLOSED") + (f="NO FWS") + ISNUMBER(f))), IF(SUM(ISERROR(res)),0,COUNTA(res)) )
 
Upvote 0
I am not understanding why you are using COUNTA(res)? I am looking for the total (sum) hours that are being charged (Columns C & L)
 
Upvote 0
In your original formula you had "FILTER(d,IFERROR(ISNUMBER(d)*(d>DATE(2020,1,1)),0", I just put the lowest date to use as a value in the Allocation Table.

Sure, I just used some date below the ones in your sample to make sure the values are dates. any date smaller than the smallest in your data will be fine.
 
Upvote 0

Forum statistics

Threads
1,215,108
Messages
6,123,133
Members
449,098
Latest member
Doanvanhieu

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