+ Reply to Thread
Results 1 to 6 of 6

Need to adapt SUM PRODUCT to measure calendar and work days each Week between dates

  1. #1
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,397

    Need to adapt SUM PRODUCT to measure calendar and work days each Week between dates

    Attached Table in A2 - E10 lists the Planned and Actual Start and Finish Dates for four Activities.

    GANTT BY MONTH in rows 29 - 37 works perfectly, using SUM PRODUCT to establish how many days each Calendar month are covered by the Date span:
    E.g. C30 (Planned Activity 1 (3rd - 10th Jan) shows 8 days in January:

    =IF(SUMPRODUCT(--(MONTH(ROW(INDIRECT($C4 & ":" & IF($D4="",TODAY(),$D4))))=MONTH(C$29)))>0,SUMPRODUCT(--(MONTH(ROW(INDIRECT($C4 & ":" & IF($D4="",TODAY(),$D4))))=MONTH(C$29))),"")

    First challenge is failing to adapt the Formula so it establishes how many days each Calendar WEEK are covered by the Date Span:

    E.g. C16 (Planned Activity 1 (3rd - 10th Jan) in week 1 SHOULD show 5 days in week 1:

    =if(SUMPRODUCT(--(WEEKNUM(ROW(INDIRECT($C3 & ":" & IF($D3="",TODAY(),$D3))))=WEEKNUM(C$15)))>0,SUMPRODUCT(--(WEEKNUM(ROW(INDIRECT($C3 & ":" & IF($D3="",TODAY(),$D3))))=WEEKNUM(C$15)))>0,"")

    Unfortunately, as shown on row 16, it generates weeks 1 - 7 as 5s, then weeks 8 - 14 as 3s (SHOULD be 5 in week 1 and 3 in week 2).

    Second challenge is the need to adapt the formula so the User can SUMPRODUCT working days (assuming Mon - Fri) as well as Calendar days.

    All solutions, alternatives and recommendations welcome as ever.

    Ochimus
    Last edited by Ochimus; 10-06-2023 at 01:23 PM.

  2. #2
    Valued Forum Contributor Root_'s Avatar
    Join Date
    07-29-2017
    Location
    _
    MS-Off Ver
    2010+
    Posts
    485

    Re: Need to adapt SUM PRODUCT to measure calendar and work days each Week between dates

    First of all, your calendar-day monthly formula can be substantially simplified like this:

    =MAX(0,MIN(IF($D3,$D3,TODAY()),EOMONTH(C$29,0))-MAX($C3,C$29)+1)

    The corresponding calendar-day weekly formula can look like this to produce the desired results:

    =MAX(0,MIN(IF($D3,$D3,TODAY()),WORKDAY.INTL(MIN($C$3:$C$10)+1,-1,"1111110")+7*C$15-1)-MAX($C3,WORKDAY.INTL(MIN($C$3:$C$10)+1,-1,"1111110")+7*(C$15-1))+1)

    I am attaching a modified file with three tabs: Calendar Days, Working days, and Selectable Calendar/Working -- see if they meet your needs.
    Last edited by Root_; 10-06-2023 at 11:02 PM.

  3. #3
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,397

    Re: Need to adapt SUM PRODUCT to measure calendar and work days each Week between dates

    Root,

    Many thanks for the prompt response, the more elegant Month formula and the Weekly solution.

    But value clarification on one point? In the Weekly formula you set the weekend as a fixed "1111110". Should that not have two options based on the Calendar/Workday choices in F3? If the formula starts the week on Sunday, and the User has selected Workdays, should that not be "0111110", and if it starts on Monday "1111100"?

    Ochimus
    Last edited by Ochimus; 10-07-2023 at 01:39 PM.

  4. #4
    Valued Forum Contributor Root_'s Avatar
    Join Date
    07-29-2017
    Location
    _
    MS-Off Ver
    2010+
    Posts
    485

    Re: Need to adapt SUM PRODUCT to measure calendar and work days each Week between dates

    The WORKDAY.INTL(MIN($C$3:$C$10)+1,-1,"1111110") is used in my formulas to calculate the first day of the first week of the date range in C3:C10. This day must fall on a Sunday as dictated by your "SHOULD be 5 in week 1 and 3 in week 2."

    If you want to have weeks starting on Monday, change all occurrences of "1111110" to "0111111". In this case, you would have 6 and 2 calendar days in cells C16 and D16.

  5. #5
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,397

    Re: Need to adapt SUM PRODUCT to measure calendar and work days each Week between dates

    Root,

    Many thanks for prompt clarification and delighted to add to your reputation.

    But can I pick your brains for one last "tweak"? I don't need it in this instance, but how should the two formulae be amended so Week 1 is the first Calendar week, and Jan is the first Month, rather than starting at the first week/month date in Col C?

    Ochimus

  6. #6
    Valued Forum Contributor Root_'s Avatar
    Join Date
    07-29-2017
    Location
    _
    MS-Off Ver
    2010+
    Posts
    485

    Re: Need to adapt SUM PRODUCT to measure calendar and work days each Week between dates

    Since "the first calendar week of the year" can be defined in a number of ways, here is a more universal solution: put your desired first day of the first week of the year in cell C14 (note: this might be a date from the previous year) and use the following simple formula in cell C16:

    =MAX(0,MIN(IF($D3,$D3,TODAY()),C$14+6)-MAX($C3,C$14)+1)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Formula to Count The Number Of Work Days between dates and in in the fiscal month
    By LCalvert in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 01-30-2020, 05:26 PM
  2. [SOLVED] Formula to calculate working days and calendar days per month-year ?
    By donny007 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-05-2018, 06:23 PM
  3. [SOLVED] populating a calendar w/product names on their due dates from dates on seperate tab
    By marcella needs help in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-25-2018, 03:35 PM
  4. Measure Cut Off Time for work done in a month
    By hazel_max in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-23-2016, 10:35 PM
  5. Replies: 2
    Last Post: 07-31-2013, 02:00 PM
  6. [SOLVED] How to measure the time elapsed between two dates in hours - not days
    By lhbarnes2002 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-31-2012, 02:31 PM
  7. [SOLVED] Sm Product a Calendar Month Range?
    By John in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-03-2005, 05:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1