+ Reply to Thread
Results 1 to 11 of 11

Calculate February Correctly for Monthly Allocation

  1. #1
    Registered User
    Join Date
    06-02-2023
    Location
    Evansville, Indiana
    MS-Off Ver
    Office 365
    Posts
    7

    Calculate February Correctly for Monthly Allocation

    Working Copy.xlsx

    Hello. I am looking for assistance with the attached document. I am assisting with a program where they used to manually calculate each month. I was asked to come up with a formula that would do it automatically. I'm 95% there, but I keep having issues with February as a 30-day month. For context, we bill using 30-day months for 360 days a year.

    OCT - JAN and MAR - SEP all calculate correctly using the following string: =$E3*((MAX(G$2-$A3,0)-MAX(DAYS(EOMONTH(G$2,-1),$A3),0))-(MAX(G$2-$B3,0)-MAX(DAYS(EOMONTH(G$2,-1),$B3),0))+(EOMONTH(G$2,0)=EOMONTH($A3,0)))

    When calculated as a full month, Columns G - R must match the monthly rate in Column D. In order to do this, I had to change the end date of each month in Row 2 to 30 for those months ending in 31.

    For FEB I had to change the formula slightly to add two days: =$E3*((MAX(K$2-$A3,0)-MAX(DAYS(EOMONTH(K$2,-1),$A3),0))-(MAX(K$2-$B3,-2)-MAX(DAYS(EOMONTH(K$2,-1),$B3),0))+(EOMONTH(K$2,0)=EOMONTH($A3,0)))

    This change is where the issue lies. When the start date is after FEB 28, the daily rate is added for those two days, which in-turn throws off the Total Amount. Without it though, the monthly rate is short two days for start dates that begin before FEB.

    Any assistance with this is greatly appreciated as I would like it to be one consistent formula throughout, rather than a separate formula for FEB.
    Last edited by Sparky156; 06-30-2023 at 08:49 PM.

  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,981

    Re: Calculate February Correctly for Monthly Allocation

    Welcome to the forum.

    I wonder if this gets you any closer?

    Please Login or Register  to view this content.
    Look at the attachment where I have mocked it up below your table.
    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
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Calculate February Correctly for Monthly Allocation

    In G3 copy to whole range.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  4. #4
    Registered User
    Join Date
    06-02-2023
    Location
    Evansville, Indiana
    MS-Off Ver
    Office 365
    Posts
    7

    Re: Calculate February Correctly for Monthly Allocation

    Good morning! I apologize for the delay in getting back with you. We had severe storms and rolling power outages.

    Thank you for replying back to my post so quickly. I was able to test and tweak the string as I was still coming up with a mix of True/False in Column Z. The following formula appears to work 99% of the time throughout the 8 programs I have tested it on:

    =IF(AND($D32<=M$30,$F32>=M$31),$K32*30,IF(AND($D32>=M$30,$F32<=M$31),(MIN(DAY($F32),30)-DAY($D32)+1)*$K32,IF(EOMONTH($F32,0)=M$31,(MIN(DAY($F32),30)+0)*$K32,IF(EOMONTH($D32,0)=M$31,(31-DAY($D32))*$K32,0))))

    There are 25+ programs that are being where this is being applied to so I will have to continue to test and develop it!

    I say 99% because there is one instance where it was off by $0.01. However, this is likely due to a rounding issue as the amount we bill does not break down evenly. The other instance was when it it did what it was supposed to and calculated February as a 30-day month. I believe this discovered a billing issue on our end where only 28 days was billed when it should have been billed for 30.

    Thank you again, I hope you're well, and thank you for welcoming me to the forum!

  5. #5
    Registered User
    Join Date
    06-02-2023
    Location
    Evansville, Indiana
    MS-Off Ver
    Office 365
    Posts
    7

    Re: Calculate February Correctly for Monthly Allocation

    Thank you for the reply. I will test this a little bit later today and get back with you! I am always looking for more than one way to complete something.

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

    Re: Calculate February Correctly for Monthly Allocation

    Pl see post#3

  7. #7
    Registered User
    Join Date
    06-02-2023
    Location
    Evansville, Indiana
    MS-Off Ver
    Office 365
    Posts
    7

    Re: Calculate February Correctly for Monthly Allocation

    Quote Originally Posted by kvsrinivasamurthy View Post
    In G3 copy to whole range.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Good evening! Thank you for this. I applied it to a number of ranges and didn't have any issues, except when one of the programs started on March 1. It calculated two days for February. I consider this another 99% solution and I'm greatly appreciative of you taking the time to look it over!

    Thank you again!

  8. #8
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,914

    Re: Calculate February Correctly for Monthly Allocation

    If start = 1/2/2023 and End = 27/2/2023, number of days will be 27 or 29?

    If start = 31/1/2023, expected result of the number of days of january: is it 1 or 0?
    Last edited by Phuocam; 07-01-2023 at 10:56 PM.

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

    Re: Calculate February Correctly for Monthly Allocation

    @ Sparky156: Here is a compact formula that handles almost every entry in the sample file as expected.
    The only exception is Line 12 (4-Feb-2023 to 28-Feb-2023). The formula treats it as a 27-day period.
    This seems logical to me since 28-Feb-2023 is the last day of the month, which is considered a 30-day month.
    If you need the last day of February handled differently, the formula can be further tweaked.

    =$E3*MAX(DAYS360(MAX($A3,EOMONTH(G$2,-1)+1),MIN($B3,EOMONTH(G$2,0))+1,0),0)

    BONUS: you don’t have to change the end date of each month in Row 2 to 30 for those months ending in 31.

    @ kvsrinivasamurthy: your formula will mishandle 29-Feb.

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

    Re: Calculate February Correctly for Monthly Allocation

    Please upload file showing the problem.

  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,981

    Re: Calculate February Correctly for Monthly Allocation

    The OP has started a new thread here: https://www.excelforum.com/excel-for...tart-date.html

    It's not a duplicate per se, but I suggest that all respondents reply in the new thread going forward.

+ 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. Replies: 1
    Last Post: 08-08-2019, 10:23 AM
  2. Sum-up weekly allocation to Monthly Allocation
    By juan.doe in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 08-11-2017, 04:41 AM
  3. [SOLVED] Move Monthly Data (January, February) into New Columns
    By msliter in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 08-24-2015, 07:03 PM
  4. Replies: 2
    Last Post: 10-30-2013, 09:50 PM
  5. Salary monthly allocation based on Hire date
    By thomas.mapua in forum Excel General
    Replies: 1
    Last Post: 08-21-2011, 08:45 PM
  6. Calculate Monthly Numbers from Monthly Averages
    By miami580 in forum Excel General
    Replies: 6
    Last Post: 08-05-2010, 11:45 AM
  7. Why does excel calculate difference in days from February - March
    By TennCare Technician in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-15-2006, 11:20 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