Contractual Weeks Calculation

August

Active Member
Joined
Jun 18, 2004
Messages
281
Office Version
  1. 365
Platform
  1. Windows
In the attached a contractual week starts at the first work day marked x and ends 7days later. The next contractual week starts on the next work day marked x and end 7 days later. The final contractual week can have less than 7 days. The No of contractual weeks for Harry would therefore be 3.
I have tried many variants of sumproducts/countifs/mod but cannot get a formula that works.
Does anyone have an idea how I could achieve the corrrect result in a formula

Many thanks
 

Attachments

  • ContWeeks.png
    ContWeeks.png
    24.8 KB · Views: 23

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
In the attached a contractual week starts at the first work day marked x and ends 7days later. The next contractual week starts on the next work day marked x and end 7 days later. The final contractual week can have less than 7 days. The No of contractual weeks for Harry would therefore be 3.
I have tried many variants of sumproducts/countifs/mod but cannot get a formula that works.
Does anyone have an idea how I could achieve the corrrect result in a formula

Many thanks
You don't really state what you are trying to find or solve for? Do you just want a list that shows how many contractual weeks each worker has?
 
Upvote 0
Contractual weeks are not linked to calendar weeks, they are 7days commencing the first day in a contractual week.
For example Martin is working in 4 calendar weeks but only has 3 contractual weeks.
1st week starts 29Oct ends after 7 days on 4Nov
2nd week starts 5Nov ends after 7 days on 11Nov
3rd week starts 15Nov ends 20Nov (final week can be less than 7 days)
I'm trying to write a formula that will give this result

Thanks
 
Upvote 0
Try this =INT((COLUMN(A1)-1)/7)+44
put it under Oct28 and make A1 = whatever cell you put this in, and the +44 is whatever you're starting on. it will + 1 every 7 columns
put that code in a cell and drag it across.
 
Upvote 0
Try this =INT((COLUMN(A1)-1)/7)+44
put it under Oct28 and make A1 = whatever cell you put this in, and the +44 is whatever you're starting on. it will + 1 every 7 columns
put that code in a cell and drag it across.
I'm looking for a formula against each name in their row giving contractual week totals. I couldn't make your solution achieve that.
 
Upvote 0
I'm looking for a formula against each name in their row giving contractual week totals. I couldn't make your solution achieve that.
oh thats funny, i had no idea that's what you were going for. the formula i gave you was to auto make the row below your yellow date row auto make the 44 x7 and 45x7 etc.. go across

try this formula next to the names of the guys. and drag it across so it goes over all the x's in their row. =COUNTIF(B5:Z5,"x")
 
Upvote 0
@August two things:
  • It's always helpful if you can show the expected answer in your example. While in this case I got 3 for Harry I don't know if the others are correct.
  • If you update your profile to show the Excel version you are using we can give a more appropriate answer for your version.
That said, does this meet your needs?
Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZ
128-Oct29-Oct30-Oct31-Oct1-Nov2-Nov3-Nov4-Nov5-Nov6-Nov7-Nov8-Nov9-Nov10-Nov11-Nov12-Nov13-Nov14-Nov15-Nov16-Nov17-Nov18-Nov19-Nov20-Nov
2Contractual444444444444444545454545454546464646464646474747
3weeksMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueWed
4Harry3xxxxxxxxxx
5John0
6Mary0
7Arthur2xx
8Wilson0
9Martin4xxxxxxxxxxx
10
Sheet1
Cell Formulas
RangeFormula
C2:Z2C2=ISOWEEKNUM(C1)
C3:Z3C3=TEXT(C1,"ddd")
B4:B9B4=IF(COUNTIFS(C4:Z4,"x")=0,0,INT((MAX(IF($C4:$Z4="x",COLUMN($C4:$Z4)))-MIN(IF($C4:$Z4="x",COLUMN($C4:$Z4))))/7)+1)


@Bond00 all your COUNTIF formula does is count occurrences of 'x', which in this case for Harry gives a value of 10.
 
Upvote 0
@August two things:
  • It's always helpful if you can show the expected answer in your example. While in this case I got 3 for Harry I don't know if the others are correct.
  • If you update your profile to show the Excel version you are using we can give a more appropriate answer for your version.
That said, does this meet your needs?
Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZ
128-Oct29-Oct30-Oct31-Oct1-Nov2-Nov3-Nov4-Nov5-Nov6-Nov7-Nov8-Nov9-Nov10-Nov11-Nov12-Nov13-Nov14-Nov15-Nov16-Nov17-Nov18-Nov19-Nov20-Nov
2Contractual444444444444444545454545454546464646464646474747
3weeksMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueWed
4Harry3xxxxxxxxxx
5John0
6Mary0
7Arthur2xx
8Wilson0
9Martin4xxxxxxxxxxx
10
Sheet1
Cell Formulas
RangeFormula
C2:Z2C2=ISOWEEKNUM(C1)
C3:Z3C3=TEXT(C1,"ddd")
B4:B9B4=IF(COUNTIFS(C4:Z4,"x")=0,0,INT((MAX(IF($C4:$Z4="x",COLUMN($C4:$Z4)))-MIN(IF($C4:$Z4="x",COLUMN($C4:$Z4))))/7)+1)


@Bond00 all your COUNTIF formula does is count occurrences of 'x', which in this case for Harry gives a value of 10.
true, forgot he just wanted week counts and not just a count of days worked per person.
 
Upvote 0
@myall_blues
If I understand correctly:
Your formula works well untill last row Martin (it should be 3, not 4)
You are supposing that week start from Monday-Sun, then week from 11-17/Nov, though he worked only Fri, but count 1.
Manual calc for Martin:
* Tue 29-Oct to Mon 4-Nov: count 1
* Tue 5-Nov to Mon 11-Nov: count 1
* Fri 15-Nov to End: count 1
 
Upvote 0
Thank you all for taking the time to reply
You are correct Martin should be 3 and contractual weeks start on the first day of work (x) not Monday.
I'll try the solution from myall_blues over the weekend and see how I get on

Again many many thanks for your time
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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