+ Reply to Thread
Results 1 to 8 of 8

ROUNDUP Formula calculating incorrectly

Hybrid View

  1. #1
    Registered User
    Join Date
    06-22-2014
    Location
    Fort Collins, CO, USA
    MS-Off Ver
    Mac 2010
    Posts
    3

    ROUNDUP Formula calculating incorrectly

    Hello. Brand new to this forum as I have exhausted my research on the web for a solution.

    I am using the following formula to calculate the period between 2 dates and then ROUNDUP to the next whole number in years with a goal of employee seniority measured in years (< 1 year equals 1, >= 1 but <2 equals 2, etc.) Basically, the result should return 3 on the 2 year anniversary date of an employee's hiring.

    =ROUNDUP(((YEAR(A10)-YEAR($B$2))*12+MONTH(A10)-MONTH($B$2))/12,0)

    $B$2 = 1/2/2006

    In this example, when A10 = 1/1/2012 the result is 6

    When A10 = 1/2/2012 the result is also 6 which would be expected. I guess I am looking to add 1 year to a result that would be a whole number prior to the application of ROUNDUP.

    HOW CAN I MODIFY THIS FORMULA TO ENSURE THE EXAMPLE WITH A10=1/2/2012 RETURNS A RESULT OF 7 INSTEAD OF 6?

    Thanks in advance for any help you folks can provide.

    Regards,

    Brian
    Last edited by busdriverbrian; 06-22-2014 at 02:28 PM.

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,455

    Re: ROUNDUP Formula calculating incorrectly

    Perhaps = DATEDIF(B2,A10,"Y")+1

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,298

    Re: ROUNDUP Formula calculating incorrectly

    It's because your criteria are set up to count "<1 year" as "Year 1", not year zero. Modify your equation:

    Formula: copy to clipboard
    =ROUNDUP(((YEAR(A10)+1-YEAR($B$2))*12+MONTH(A10)-MONTH($B$2))/12,0)
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  4. #4
    Registered User
    Join Date
    06-22-2014
    Location
    Fort Collins, CO, USA
    MS-Off Ver
    Mac 2010
    Posts
    3

    Re: ROUNDUP Formula calculating incorrectly

    Thanks Glenn. I actually do want "<1 year" as "Year 1", but want "Year => 1 < 2" to give a result of "Year 2".

    Essentially, a person is hired on 1/2/2013 and will be considered "Year 1" until their hire anniversary date on 1/2/2014 at which time they will be considered "Year 2." My original formula works properly accept when rounding up the the same dates on different years. Rounding up the integer 2 results in 2 when I want it to be 3. Thanks again for the help.

  5. #5
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: ROUNDUP Formula calculating incorrectly

    welcome to the forum. did you try Pepe's formula in post #2? just add the dollar signs if you need to for cell B2:
    =DATEDIF($B$2,A10,"Y")+1

    this calculates the complete number of years between 2 dates. he then adds 1 to it because you want it rounded up regardless of how many incomplete months there are.

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  6. #6
    Registered User
    Join Date
    06-22-2014
    Location
    Fort Collins, CO, USA
    MS-Off Ver
    Mac 2010
    Posts
    3

    Re: ROUNDUP Formula calculating incorrectly

    It looks like Pepe's solution did the trick. Thank you to everyone for your help on this. Much appreciated.

    Brian

  7. #7
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,455

    Re: ROUNDUP Formula calculating incorrectly

    Quote Originally Posted by benishiryo View Post
    welcome to the forum. did you try Pepe's formula in post #2? just add the dollar signs if you need to for cell B2:
    =DATEDIF($B$2,A10,"Y")+1

    this calculates the complete number of years between 2 dates. he then adds 1 to it because you want it rounded up regardless of how many incomplete months there are.
    Thanks Beni. I've often seen that OP's tend to look at the last post, without checking out the others . Why? I don't know

  8. #8
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: ROUNDUP Formula calculating incorrectly

    @Pepe:
    you're welcome. i encountered that myself countless of times too.


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

+ 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. Pivot Table Calculating Incorrectly?
    By orcsab in forum Excel General
    Replies: 1
    Last Post: 03-16-2012, 02:09 AM
  2. Excel incorrectly calculating sumproduct
    By cmf0106 in forum Excel General
    Replies: 1
    Last Post: 11-23-2009, 01:13 PM
  3. formulas calculating incorrectly
    By Toidz77 in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 08-22-2009, 09:35 AM
  4. Function in spreadsheet calculating incorrectly
    By pboost1 in forum Excel Formulas & Functions
    Replies: 28
    Last Post: 01-13-2009, 04:58 PM
  5. Macro calculating incorrectly.. what can cause this?
    By Celt in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-09-2006, 12:10 AM

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