+ Reply to Thread
Results 1 to 19 of 19

Allocate amount into monthly columns-formula fails for specific years - NETWORKDAYS issue?

  1. #1
    Registered User
    Join Date
    06-27-2009
    Location
    Miami, FL
    MS-Off Ver
    Excel 2010
    Posts
    7

    Allocate amount into monthly columns-formula fails for specific years - NETWORKDAYS issue?

    I've been using an incredibly helpful spreadsheet (attached here) but it seems to fail specifically for the years 2022 and 2023. My steps are:

    1) In the "Start Here" tab, change Allocation Table Start Date to 1/1/22
    2) In the "Weekdays" tab, change dates for one of the rows to 1/1/22-12/31/22

    Now the Total (column W) doesn't match the planned amount (column B).

    This problem disappears if the end date is 12/30, or if the year isn't 2022 or 2023. I am baffled and dismayed. Can anyone diagnose this? Thank you!
    Attached Files Attached Files
    Last edited by panaceus; 02-10-2022 at 12:46 PM.

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,152

    Re: Allocate amount into monthly columns-formula fails for specific years - NETWORKDAYS is

    this formula adds an extra day because of the highlighted condition so working days for January are 22 rather 21 from NETWORKDAYS with dates 0f 1st Jan to 31st Jan

    =$G11*((MAX(NETWORKDAYS($C11,H$10),0)-MAX(NETWORKDAYS($C11,EOMONTH(H$10,-1)),0))-(MAX(NETWORKDAYS($D11,H$10),0)-MAX(NETWORKDAYS($D11,EOMONTH(H$10,-1)),0))+(EOMONTH(H$10,0)=EOMONTH($C11,0)))
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  3. #3
    Valued Forum Contributor janmorris's Avatar
    Join Date
    07-24-2021
    Location
    Japan
    MS-Off Ver
    Google Sheets (& Mac 2021)
    Posts
    1,066

    Re: Allocate amount into monthly columns-formula fails for specific years - NETWORKDAYS is

    in the hope of finding why the formula fails for 2022, ive been doing some testing (Excel for Mac 2021).

    for 2022, if the dates on Weekdays are set to:

    1 jan 2022 - 31 jan 2022 = NO problem
    1 nov 2022 - 30 nov 2022 = NO problem
    1 oct 2022 - 31 oct 2022 = NO problem

    1 oct 2022 - 31 dec 2022 PROBLEM for october
    1 nov 2022 - 31 dec 2022 PROBLEM for november
    1 dec 2022 - 31 dec 2022 PROBLEM for december

    so it seems there is something going on with the totals whenever the final date is 31 dec 2022

    i have tested years from 2000 - 2030, and this problem occurs in the following years:

    2000 > 31 dec is a Sun
    2005 > 31 dec is a Sat
    2006 > 31 dec is a Sun
    2011 > 31 dec is a Sat
    2016 > 31 dec is a Sat
    2017 > 31 dec is a Sun
    2022 > 31 dec is a Sat
    2023 > 31 dec is a Sun
    2028 > 31 dec is a Sun

    Notice that these are all the years where the last day of the year is a Saturday or Sunday (A)

    i used this perpetual calendar:
    https://r-knott.surrey.ac.uk/PerpetualCalendar.html

    Screen Shot 2022-02-09 at 12.06.37 pm.png
    Last edited by janmorris; 02-09-2022 at 01:30 AM.

  4. #4
    Valued Forum Contributor janmorris's Avatar
    Join Date
    07-24-2021
    Location
    Japan
    MS-Off Ver
    Google Sheets (& Mac 2021)
    Posts
    1,066

    Re: Allocate amount into monthly columns-formula fails for specific years - NETWORKDAYS is

    based on my findings i whipped up this formula, which seems to work.

    put it into cell Weekdays!H11, then drag it across to U11, then drag the row down
    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Valued Forum Contributor janmorris's Avatar
    Join Date
    07-24-2021
    Location
    Japan
    MS-Off Ver
    Google Sheets (& Mac 2021)
    Posts
    1,066

    Re: Allocate amount into monthly columns-formula fails for specific years - NETWORKDAYS is

    well... further testing has shown the problem occurs for ANY period where the last day of the period is a Saturday or Sunday... so dont use the formula above.. it is false hope... sorry

    back to the drawing board and make a new formula.


    Ok.. i think its fixed now

    using this new formula:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by janmorris; 02-09-2022 at 02:16 AM.

  6. #6
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,577

    Re: Allocate amount into monthly columns-formula fails for specific years - NETWORKDAYS is

    Pl see file. In H11 copied across.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by kvsrinivasamurthy; 02-09-2022 at 02:50 AM.
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  7. #7
    Valued Forum Contributor janmorris's Avatar
    Join Date
    07-24-2021
    Location
    Japan
    MS-Off Ver
    Google Sheets (& Mac 2021)
    Posts
    1,066

    Re: Allocate amount into monthly columns-formula fails for specific years - NETWORKDAYS is

    @kvsrinivasamurthy

    if the end date is not the last day of the month (i tested this with a date range of 1/jan/2022 - 29/dec/2022) then it adds extra allocation.

  8. #8
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,577

    Re: Allocate amount into monthly columns-formula fails for specific years - NETWORKDAYS is

    Yes, @janmorris . Thanks for pointing it out.
    I have checked and corrected.
    Corrected formula.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,152

    Re: Allocate amount into monthly columns-formula fails for specific years - NETWORKDAYS is

    Ss far as I can judge, this is completely redundant as it will apply to whatever is the starting month: there is no obvious rationale for it so simple remove from the formula


    + (EOMONTH(H$10,0)=EOMONTH($C11,0)))

  10. #10
    Valued Forum Contributor janmorris's Avatar
    Join Date
    07-24-2021
    Location
    Japan
    MS-Off Ver
    Google Sheets (& Mac 2021)
    Posts
    1,066

    Re: Allocate amount into monthly columns-formula fails for specific years - NETWORKDAYS is

    @JohnTopley

    it adds a day when necessary, so taking it out can cause an imbalance.

    and although my second formula does something about the years with last day on a weekend, what you have pointed out has shown my 2nd formula to be inefficient.... and since this caused me to take another look, i noticed that if the last date of the range is not the last date of the month, then there is still misallocation using my formula.

    so far i have tested the second formula from kvsrinivasamurthy which is not only much shorter, it has also proven to be correct.

    i wonder where the OP is and if they have anything to say.

  11. #11
    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,460

    Re: Allocate amount into monthly columns-formula fails for specific years - NETWORKDAYS is

    The OP is in Florida, where it is currently 0410. I am sure (s)he will respond when they are up and at it. It isn't unusual for someone to post a query and come back to see what has been suggested 24 hours later.
    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.

  12. #12
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,152

    Re: Allocate amount into monthly columns-formula fails for specific years - NETWORKDAYS is

    it adds a day when necessary, so taking it out can cause an imbalance.
    It ALWAYS adds a day whatever the starting month ($C11): the dates in row 10 are end of month so the test will always be true when the date (month) in row 10 is the same as month in $C11. So with start date of 01/06/2022 result is 23 days not 22 (from network,days) in June.

    Why is it added at all as WEEKDAYS should equal F11?
    Last edited by JohnTopley; 02-09-2022 at 05:23 AM.

  13. #13
    Valued Forum Contributor janmorris's Avatar
    Join Date
    07-24-2021
    Location
    Japan
    MS-Off Ver
    Google Sheets (& Mac 2021)
    Posts
    1,066

    Re: Allocate amount into monthly columns-formula fails for specific years - NETWORKDAYS is

    @JohnTopley
    Why is it added at all as WEEKDAYS should equal F11?
    im not sure, i wondered the same thing myself... this is what they teach at university (excel-university to be exact, hahaha: https://www.excel-university.com/exc...nthly-columns/)


  14. #14
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,152

    Re: Allocate amount into monthly columns-formula fails for specific years - NETWORKDAYS is

    The example at Excel_University is NOT using NETWORKDAYS so adding the EOMONTH check IS redundant.

  15. #15
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Allocate amount into monthly columns-formula fails for specific years - NETWORKDAYS is

    Please try at H11

    =MAX(0,NETWORKDAYS(MAX($C11,EOMONTH(H$10,-1)+1),MIN(H$10,$D11)))*$G11
    Attached Files Attached Files

  16. #16
    Valued Forum Contributor janmorris's Avatar
    Join Date
    07-24-2021
    Location
    Japan
    MS-Off Ver
    Google Sheets (& Mac 2021)
    Posts
    1,066

    Re: Allocate amount into monthly columns-formula fails for specific years - NETWORKDAYS is

    Quote Originally Posted by JohnTopley View Post
    The example at Excel_University is NOT using NETWORKDAYS so adding the EOMONTH check IS redundant.
    yes it is.. here is the untouched file, and a screenshot to boot:

    Screen Shot 2022-02-09 at 9.30.53 pm.png
    Attached Files Attached Files

  17. #17
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,152

    Re: Allocate amount into monthly columns-formula fails for specific years - NETWORKDAYS is

    O.K!!! but it is wrong!

  18. #18
    Registered User
    Join Date
    06-27-2009
    Location
    Miami, FL
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Allocate amount into monthly columns-formula fails for specific years - NETWORKDAYS is

    Thanks so much everyone, and apologies for the late reply! Thanks especially to janmorris for the detailed testing, and kvsrinivasamurthy for the pithy implementation. This was a tricky one

    Edit: Bo_Ry, I appreciate your version as well.
    Last edited by panaceus; 02-10-2022 at 12:40 PM.

  19. #19
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,577

    Re: Allocate amount into monthly columns-formula fails for specific years - NETWORKDAYS is

    Thanks for feedback.

+ 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. Formula to add specific amount of years to a date
    By WinterTom in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-23-2021, 11:57 PM
  2. [SOLVED] Total Amount spreading into monthly columns
    By krishco in forum Excel General
    Replies: 6
    Last Post: 11-24-2018, 03:22 AM
  3. [SOLVED] Formula to Allocate Numbers into Monthly Columns
    By VICTOR5 in forum Excel General
    Replies: 16
    Last Post: 07-30-2017, 02:41 AM
  4. Create a formula to allocate the amount into appropriate cells
    By kevin211288 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-02-2016, 06:35 PM
  5. sum monthly amount columns to quarterly columns in separate worksheet
    By rirunnels in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-10-2015, 11:27 AM
  6. Replies: 5
    Last Post: 09-30-2010, 08:02 PM
  7. [SOLVED] How do I keep up with a monthly amount due from past years?
    By hotsytotsy79 in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 07-18-2005, 02:05 PM

Tags for this Thread

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