+ Reply to Thread
Results 1 to 4 of 4

Extremely Weird Math Bug !! Formula is correct, but Excel aggregates wrong!!

  1. #1
    Forum Contributor
    Join Date
    10-10-2018
    Location
    Calgary, Canada
    MS-Off Ver
    2016
    Posts
    214

    Extremely Weird Math Bug !! Formula is correct, but Excel aggregates wrong!!

    Please see attached spreadsheet, showing the mathematical error. You'll see in Column B is a repeating formula that calculates an integer number that changes every 14 days on a Tuesday.

    The problem is in line 47, where suddenly thereafter it changes the integer number every Monday!!

    If you dissect the formula:

    =IF(ABS(B46-TRUNC(B46)) + ((A47-A46)*0.01) > 0.01*$C$4, TRUNC(B46)+1.01, B46 + ((A47-A46)*0.01))

    The blue formula calculates as FALSE, and yet the TRUE part of the IF statement (red) is executed!!!

    Does anyone know why? Thanks!!!
    Attached Files Attached Files

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Extremely Weird Math Bug !! Formula is correct, but Excel aggregates wrong!!

    Why is it happening: floating point arithmetic (read more here) is causing the initial criteria to evaluate TRUE.


    How did I find that out: Formula > Formula Auditing > Evaluate Formula > Click Evaluate to work through exactly what the formula is doing.

    Capture.PNG


    How to fix the problem: Introduce a ROUND function:

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Forum Contributor
    Join Date
    10-10-2018
    Location
    Calgary, Canada
    MS-Off Ver
    2016
    Posts
    214

    Re: Extremely Weird Math Bug !! Formula is correct, but Excel aggregates wrong!!

    wow!! thanks!!

  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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,418

    Re: Extremely Weird Math Bug !! Formula is correct, but Excel aggregates wrong!!

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.
    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.

+ 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: 10
    Last Post: 02-21-2019, 10:42 AM
  2. [SOLVED] Weird Excel Math
    By liquidmettle in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-30-2015, 07:55 AM
  3. Replies: 3
    Last Post: 10-10-2014, 08:14 AM
  4. [SOLVED] Area between weird curves made out of lines (math problem?)
    By dejhantulip in forum Excel General
    Replies: 4
    Last Post: 04-04-2012, 07:07 PM
  5. [SOLVED] Fill down produces correct formula but wrong answer
    By Jim at SDSU in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-03-2006, 03:10 PM
  6. Replies: 3
    Last Post: 02-16-2006, 07:00 AM
  7. Formula correct, answer wrong
    By TJAC in forum Excel General
    Replies: 2
    Last Post: 01-03-2006, 02: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