+ Reply to Thread
Results 1 to 16 of 16

Inconsistent results from excel rows

Hybrid View

  1. #1
    Registered User
    Join Date
    01-26-2015
    Location
    Canada
    MS-Off Ver
    Office Professional Plus 2010
    Posts
    16

    Inconsistent results from excel rows

    Hi folks,

    With the help of many other forum users I have created a great time sheet. I was playing around with it and it yields in consistent results. I have attahed an example sheet for you to see.

    Paramaters
    When there are exactly 2 hours or less worked the result should be 3 hours of STO. One minute over that total and it should go to THO for the first 2 hours and DTO for any time after the 2 hours. Why do the various rows yeild different results?

    If you notice all entries are 2 hours some one minute above and below. Excel seems to have difficulty managing the threshold of 2 hours as some entries are correct, others are THO (rows 14, 17, 20, 23, 26, 29), one is DTO (row 13) yet all the formulas are exactly the same. It is every 3rd row, not sure what causes this.

    Any suggestions? Any help is greatly appreciated.

    Russell
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,279

    Re: Inconsistent results from excel rows

    Change your formula in G11 from

    =SUM(MOD(E11-C11,1)*96,0)/4

    to

    =ROUND(MOD(E13-C13,1)*96,0)/4

    That rounds to the nearest 15 minutes, which I think is your intent, which should also clear up your other issues.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    01-26-2015
    Location
    Canada
    MS-Off Ver
    Office Professional Plus 2010
    Posts
    16

    Re: Inconsistent results from excel rows

    For some reason this does not change the results. Interesting how it is not every row?

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,279

    Re: Inconsistent results from excel rows

    When I used that in your worksheet, all the results changed. Did you copy it down the entire column to match you time entries?

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Inconsistent results from excel rows

    This would probably be a LOT simpler/easier if you stuck to time, instead of trying to convert to full numbers.

    2 hours simply becomes 2/24 etdc. No need for MOD's or ROUNDS or anything
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  6. #6
    Registered User
    Join Date
    01-26-2015
    Location
    Canada
    MS-Off Ver
    Office Professional Plus 2010
    Posts
    16

    Re: Inconsistent results from excel rows

    Hey Ford,
    Thanks for the help. I am relatively new to the complexity of these formula's. What I am trying to design with the help of lots of forum users is a TS where I can simply enter my times and it automatically calculates the appropriate STO, THO, and DTO. at the end of the pay period I simply take my totals and enter those into my pay system and get paid out. Is there a simpler formula you are aware of?

    Thanks,
    Russ

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Inconsistent results from excel rows

    Keep in mind that time is just a decimal of 1 (day), so for instance 06:00 AM is actualy just 0.25, 12 noon is .05 and 06:00 PM (18:00) is 0.75. Excel formats it to something we see as a time

    So, this means a complete "re-tooling" of your formulas and formats.

    I am ding this in Row 14 (coz you have some numbers to test with there)
    G14=E14-C14
    H14=IF(G14=0,0,IF(Q14<2/24,3/24,0))
    I14=IF(G14>2,MIN(2/24,G14),"")
    J14==MAX(0,G14-H14+I14)
    Format all these to Custom h:mm

    The rest of your formulas in that table look OK, maybe need to adjujst some formatting.

    I find it far easier to generally stick with the unit you are working with, that way you dont need to fiddle around with conversions

  8. #8
    Registered User
    Join Date
    01-26-2015
    Location
    Canada
    MS-Off Ver
    Office Professional Plus 2010
    Posts
    16

    Re: Inconsistent results from excel rows

    For some reason I cannot make some of these formula's work, it appears to do the same thing around the 2 hour threshold. One minute over or under the 2 hour threshold and it works well. Exactly 2 hours appears to be difficult for excel. When I changed the formula for I14, it did not calculate any values at any point. Excel gives the error message “error in value” for the formula in J14 as well. I changed the formula’s, formatting and copied down. I may be doing something wrong.
    Thanks,
    Russ

  9. #9
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,279

    Re: Inconsistent results from excel rows

    I'm not sure what is wrong with the formula I used:

    After Hours - Example Sheet - Draft.xlsx

  10. #10
    Registered User
    Join Date
    01-26-2015
    Location
    Canada
    MS-Off Ver
    Office Professional Plus 2010
    Posts
    16

    Re: Inconsistent results from excel rows

    Hey Bernie,
    I have downloaded your version and the parameters I am looking for are as follows:

    When there are exactly 2 hours or less worked the result should be 3 hours of STO. One minute over that total and it should go to THO for the first 2 hours and DTO for any time after the 2 hours.

    Unfortunately where I work they require "exact time" so all entries must be exact. In your sheet when the times areentered at exactly 2 hours rows 13-24 result in 2 hours of DTO and rows 25-30 result in THO. All entries with exactly 120 minutes or less must result in 3 hours of STO and anything 121 minutes and up need to result in the first 120 minutes being THO and anything over 121 minutes being DTO. For example, I work 45 minutes and enter my time of 10 Pm to 10:45 Pm I would get paid 3 hours of STO. If I were to work 2' 45" and I enter my time from 4Pm to 6:45PM then the result should read 2 hours THO and 45 minutes of DTO. If I were to work 121 minutes it should result in 120 minutes of THO and 1 minute of DTO.

    I am I being too exuberant? Perhaps what I am asking is too much for excel to handle? Maybe I just have to revert to a manual entry of time and the resulting OT will be calculated based on the manual entry of "worked" time entry.

    I really appreciate your efforts in trying to help me so please dont take this the wrong way, it is just the way my employer tracks OT.

    Thanks,
    Russ

  11. #11
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Inconsistent results from excel rows

    See the attached. I had to add in a roundup() function to handle the decimal fluctuations

    I added my formulas from G13:I13 down, and left your formulas in 11:12 as you had them so you can compare
    I also changed some times (highlighted yellow) to test, and it seems to be doing what you wsaked for. Test it again and let me know?
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    01-26-2015
    Location
    Canada
    MS-Off Ver
    Office Professional Plus 2010
    Posts
    16

    Re: Inconsistent results from excel rows

    That is getting closer, but there continues to be problems with exactly 2 hours as it lists 3 hours STO and 2 hours of THO. It should only list 3 hours of STO. It works great one minute over or under the 2 hour mark. Excel just really appears to struggle with any time listed exactly at 2 hours.

  13. #13
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Inconsistent results from excel rows

    OK, put this in I13 amd copy down (and up)...
    =IF(G13>ROUNDUP(2/24,10),MIN(ROUNDUP(2/24,10),G13),"")
    I changed from >= to just >

  14. #14
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,943

    Re: Inconsistent results from excel rows

    There maybe a problem with the way the times were entered. It seems like the initial times were entered in row 13 and dragged down to fill. So when you get to 12:00 and after, the decimal values are 1.0... not 0.00 ...

    So, if you manually enter a time after 12 am the the decimal value is less than 1 and some of the formulas error.
    Ben Van Johnson

  15. #15
    Registered User
    Join Date
    01-26-2015
    Location
    Canada
    MS-Off Ver
    Office Professional Plus 2010
    Posts
    16

    Re: Inconsistent results from excel rows

    That is true, I did put in times and copy down. I have also tried manually entering the times and it yields the same results. For some reason, the vast majority of any entries of exactly 2 hours excel does not deal with well. If it is one minute under (119 minutes) or one minute over (121 minutes) excel does a great job of those, but exactly 120 minutes it cannot handle. I have no explanation.

    Thanks for the look and effort though,
    Russ

  16. #16
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: Inconsistent results from excel rows

    Quote Originally Posted by Russ15 View Post
    Any suggestions? Any help is greatly appreciated.
    I think the worksheet "fix" in the file "russ fixed.xlsx" (click on the file name) does what you intended. The formulas:
    C14:  =--TEXT(MOD(C13+"1:00",1),"hh:mm")	
    E13:  =--TEXT(MOD(C13+"2:00",1),"hh:mm")	
    G11:  =IF(AND(ISNUMBER(C11),ISNUMBER(E11)),ROUND(MOD(E11-C11,1)*96,0)/4,"")
    H11:  =IF(N(G11)=0,"",IF(G11<=2,3,""))
    I11:  =IF(N(G11)>2,2,"")
    J11:  =IF(N(G11)>2,ROUND(G11-2,2),"")
    Copy C14 down through C30
    Copy D13 down through E30
    Copy G11:J11 down through G35:J35
    Similar changes in G53:I78
    In Russ'soriginal design, columns G:J represented hours as a decimal number. There is no need to change that, as FDibbins did. In fact, I think the change to hh:mm representation complicates the arithmetic.

    The formulas in columns C and E ensure that time is rounded to the minute with the correct binary representation. That was part of Russ's original problem: the unrounded time arithmetic (Fill Series) created infinitesimal binary anomalies.

    The formula in column G is essentially the correction that Bernie suggested: replacing SUM with ROUND. Bernie's change did not seem to work as intended because of mistakes in Russ's original formula, to wit:

    1. In column H, =IF(G11=0,0,IF(G11<2,3,0)) should be =IF(G11=0,0,IF(G11<=2,3,0)).

    2. The formula in I11, =IF(G11>2,MIN(2,G11),""), is changed to =IF(G25>=2,MIN(2,G25),"") starting in I25.

    The N() function in columns H:I allow for the value in column G to be the null string ("").

    I believe the formulas in columns H:I resolve ambiguities in Russ's description. But only Russ can confirm that. The ambiguities are described below.

    In another discussion, Russ wrote:
    Quote Originally Posted by Russ15 View Post
    If you work 2 hours or less you get paid 3 hours of straight time over time (STO)

    If you work 2 hours or more you get paid the first 2 hours at 1 1/2 (1.5X) times (THO) and the rest at 2X (DTO).
    For exactly 2 hours, there would be results in both STO and THO. I don't believe that is the intention.

    In fact, in this discussion, Russ wrote:
    Quote Originally Posted by Russ15 View Post
    When there are exactly 2 hours or less worked the result should be 3 hours of STO.

    One minute over that total and it should go to THO for the first 2 hours and DTO for any time after the 2 hours.
    Thus, the formula in column H is =IF(N(G11)=0,"",IF(G11<=2,3,"")).

    And the formulas in column I:J are =IF(N(G11)>2,2,"") and =IF(N(G11)>2,ROUND(G11-2,2),"").

    However, there is still an ambiguity. Russ wrote "one minute over that". But in fact, his original formula rounds to the nearest quarter-hour.

    So in fact, 7 minutes or less over 2 hours is rounded to 2 hours. So 3 hours of STO is recorded. See row 31.

    But 8 minutes or more over 2 hours is rounded to 2.25 hours or more. So THO and DTO time are recorded. See row 32.

    Finally....

    It seems odd to me that effectively time-and-one-half (3) is record in STO, but just time (2) and time-over-two are recorded for THO and DTO.

    Quote Originally Posted by Russ15 View Post
    That is true, I did put in times and copy down. [....] For some reason, the vast majority of any entries of exactly 2 hours excel does not deal with well. If it is one minute under (119 minutes) or one minute over (121 minutes) excel does a great job of those, but exactly 120 minutes it cannot handle. I have no explanation.
    See the comment about unrounded time arithmetic above. If that is not sufficient, I can explain in more detail.

    In a nutshell, Excel time is represented as a fraction of a day. And with the binary representation that Excel (and most applications) uses internally, most non-integer values cannot be represented exactly. These infinitesimal differences cause the result of most arithmetic to be different from mathematical expectations.

+ 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] Inconsistent results from HLOOKUP
    By y_not in forum Excel General
    Replies: 2
    Last Post: 11-27-2014, 04:47 AM
  2. Inconsistent results for formula
    By Maxwel in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-27-2014, 08:04 PM
  3. [SOLVED] Inconsistent if(and(or results, HELP!!
    By Groovicles in forum Excel Formulas & Functions
    Replies: 16
    Last Post: 08-03-2013, 11:50 AM
  4. Inconsistent IF Results
    By BW29 in forum Excel General
    Replies: 3
    Last Post: 12-20-2010, 10:12 AM
  5. [SOLVED] Excel/Outlook Inconsistent results
    By Don Rouse in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-08-2005, 03: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