+ Reply to Thread
Results 1 to 14 of 14

Excluding vacation days in calculations

  1. #1
    Registered User
    Join Date
    01-02-2022
    Location
    Colorado
    MS-Off Ver
    Microsoft Office 365
    Posts
    22

    Excluding vacation days in calculations

    I'm getting ever so close to figuring things out with my Excel project, all thanks to the excellent help I've received here. Now I'm on to doing additional calculations based on set vacation days. So this is the jist of the workbook:

    1. Calculate the last payday in any given month - this could be either a Tuesday, Wednesday, or Friday
    Based on the above formula, I now have a "work period", basically the last payday from the previous month to the day prior to the last payday in the current month.
    2. One person works every day in that "work period"
    3. One person only works on Monday and Tuesday, and every other Sunday (Sunday must be an "even" WEEKNUM)

    So far I've gotten these done. With the help of AliGW, I was able to figure out how many "working" Sundays are in that "work period". Now I'm stuck on figuring out the vacation days. These are set days for various events. The way they apply is:

    a) For the one person working every possible day, ALWAYS subtract the amount of vacation days for that "work period"
    b) For the person only working part of the time, ONLY subtract the vacation day if it happens to fall on one of their work days (Mon, Tues, or the Sunday they work)

    The attached workbook has a list of the vacation days, and the current state of the calculations as I've done them. I have two questions:

    1. Looking at the formula for the vacation days, I don't entirely understand why I had to do a +1 to get the correct number. I'm using NETWORKDAYS.INTL to filter things out based on the list of vacation days, and subtracting it from the total work days. But somewhere I am losing what's inclusive and what's exclusive in the date ranges and doing the +1 seems to fix that. If someone could explain that to me I would appreciate it.

    2. How can I calculate when a vacation day falls on any of the workdays for Person 2 and only subtract those? If a vacation day falls on a day they're not working, it doesn't need to get subtracted.

    I hope I explained this well enough. If not, please ask for clarifications and I will attempt to explain again, or in a different way, if possible.
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,853

    Re: Excluding vacation days in calculations

    In O10 copied down:

    =SUMPRODUCT(($C$5:$C$14>=I9)*($C$5:$C$14<=I10))
    Attached Files Attached Files
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    01-02-2022
    Location
    Colorado
    MS-Off Ver
    Microsoft Office 365
    Posts
    22

    Re: Excluding vacation days in calculations

    Ok, that is a much easier way of doing the calculations for how many vacation days there are in the given work period. I feel like I'm always overthinking things. Now, how do I work out the 2nd part: only subtracting vacation days from Person 2 if it falls on one of their workdays?

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,853

    Re: Excluding vacation days in calculations

    Try this:

    =SUM(J10:L10)-SUMPRODUCT(($C$5:$C$14>=I9)*($C$5:$C$14<=I10)*(WEEKDAY($C$5:$C$14,1)<>2)*(WEEKDAY($C$5:$C$14,1)<>4))-SUMPRODUCT(($C$5:$C$14>=I9)*($C$5:$C$14<=I10)*(WEEKDAY($C$5:$C$14,1)=1)*(MOD($V$5:$V$14,2)=0))
    Attached Files Attached Files
    Last edited by AliGW; 01-19-2022 at 05:10 AM.

  5. #5
    Registered User
    Join Date
    01-02-2022
    Location
    Colorado
    MS-Off Ver
    Microsoft Office 365
    Posts
    22

    Re: Excluding vacation days in calculations

    Hi AliGW, once again, thank you for your response. Before I try that, I'd like to understand how you approach this. In my mind I'm trying to figure it out and this is what I came up with ...
    The goal is to subtract only those vacation days from Person 2's work days if they fall on one of their work days. In trying to figure out how to do that, I'm thinking I need to know all the vacation days (we have that) and I need to know their work days. Their TOTAL work days has been calculated by counting all the Mondays, Tuesdays, and those Sundays that they would work. The part I don't know is how do I get dates to compare, and how I should be doing that comparison. OR, if I should be thinking more in terms of converting things into TRUE/FALSE conditions and going that route ...

    Now, I haven't tried your solution yet, but could you perhaps briefly look over my logic for solving the goal and tell me if I'm even on the right track?

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,853

    Re: Excluding vacation days in calculations

    I have taken a slightly different approach - I think yours will take you into a dead end.

    I'd really like to know if what I suggested has worked for you, as I did spend quite a while on it for it not to be tested.

    If it does work, then I can explain my logic to you.

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,853

    Re: Excluding vacation days in calculations

    OK, so when you confirm whether or not my solution works for you, I'll take the discussion further, if necessary. If you are waiting for something more from me before you test my solution, then I am afraid there is nothing more for me to add.

  8. #8
    Registered User
    Join Date
    01-02-2022
    Location
    Colorado
    MS-Off Ver
    Microsoft Office 365
    Posts
    22

    Re: Excluding vacation days in calculations

    Absolutely, I understand that. I'm running around doing some errands right now but will have time this afternoon to test your solution. I appreciate your help!

  9. #9
    Registered User
    Join Date
    01-02-2022
    Location
    Colorado
    MS-Off Ver
    Microsoft Office 365
    Posts
    22

    Re: Excluding vacation days in calculations

    I got a chance to test your provided solution and it appears to work for some months but not others. I took the time to write out every single month and highlighted the work periods. Then I went through and marked every work day and added them up. You can see all that data on the second sheet in the attached file. After counting the days, some of them align with your calculations but for some reason others don't.

    Now I will admit that I may be completely oblivious to something here and it's possible that your solution is correct but my manual data entry is wrong. I've been staring at this for far too long.
    Attached Files Attached Files

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,853

    Re: Excluding vacation days in calculations

    I think I have resolved it. This works:

    =SUM(J10:L10)-SUMPRODUCT(($C$5:$C$14>=I9)*($C$5:$C$14<I10)*(WEEKDAY($C$5:$C$14,1)=2))-SUMPRODUCT(($C$5:$C$14>=I9)*($C$5:$C$14<I10)*(WEEKDAY($C$5:$C$14,1)=3))-SUMPRODUCT(($C$5:$C$14>=I9)*($C$5:$C$14<I10)*(WEEKDAY($C$5:$C$14,1)=1)*(MOD($V$5:$V$14,2)=0))

    Now I will admit that I may be completely oblivious to something here ...
    We both were! There was a miscalculation in the base formula for calculating Mondays, Tuesdays and Sundays that manifested itself in May because it was including the end payday. I have amended it thus:

    =SUMPRODUCT(--(WEEKDAY(ROW(INDIRECT(I9&":"&I10-1)), 2) = 1))

    I've also amended all other formulae that refer to the end of the range to exclude the payday. Let me know if you are now happy.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.
    Attached Files Attached Files
    Last edited by AliGW; 01-21-2022 at 04:52 AM.

  11. #11
    Registered User
    Join Date
    01-02-2022
    Location
    Colorado
    MS-Off Ver
    Microsoft Office 365
    Posts
    22

    Re: Excluding vacation days in calculations

    Aaaaah there it is! I had to uncover the column where you were calculating the WEEKNUM separately (did that the last post) but it's all there. It all works as expected. Now for the fun part, me going bit-by-bit through it to understand the calculations and how it's done. As always, thank you so much! And as of right now I am not allowed to give you more reputation but you have my appreciation. Cheers!

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,853

    Re: Excluding vacation days in calculations

    Just shout here if you need any explanation. I enjoyed the challenge!

  13. #13
    Registered User
    Join Date
    01-02-2022
    Location
    Colorado
    MS-Off Ver
    Microsoft Office 365
    Posts
    22

    Re: Excluding vacation days in calculations

    So a couple of things that immediately became apparent to me early on:
    1. I didn't know I could use an entire range to compare against a single cell. I always assumed it had to be done cell-to-cell. For example:
      Please Login or Register  to view this content.
    2. I'm slowly learning to use TRUE/FALSE conditions and using SUMPRODUCT to get the actual numbers I need. It's funny that I know to do this in other programming languages, but never considered the possibility of doing it in an Excel formula.
    3. Learning to use F9 to debug the conditions within each formula. This has, by far, been the biggest help in understanding what I was working with in the formula.

  14. #14
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,853

    Re: Excluding vacation days in calculations

    I have found Evaluate Formula on the Formulas ribbon to be very useful when learning more complex formulae.

+ 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. Track vacation days accrued vs days out in the field
    By LuckyLuis in forum Excel General
    Replies: 4
    Last Post: 08-10-2017, 10:47 PM
  2. Formula for vacation days earned annualy with additional days at a milestone
    By poTATEohhh in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-29-2015, 08:40 AM
  3. [SOLVED] Earned & Used Vacation calculations based on Hire Date
    By NerdALRT in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-11-2015, 01:26 PM
  4. Replies: 4
    Last Post: 05-19-2014, 04:28 PM
  5. Work Schedule that calculates hours, lunches, days off and vacation days
    By tameronstarr in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-12-2014, 12:06 PM
  6. Calculate vacation days taken or partial days
    By chris1965 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-20-2013, 07:18 PM
  7. Vacation Days Taken vs Vacation Days Scheduled
    By Gtrtim112 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-30-2013, 02:44 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