+ Reply to Thread
Results 1 to 9 of 9

IF Function is not returning correct number for all cells

  1. #1
    Registered User
    Join Date
    08-24-2021
    Location
    Minnesota
    MS-Off Ver
    365
    Posts
    33

    IF Function is not returning correct number for all cells

    If you look at the data under "Chart 1.3" the formula says that if the number on page "20 Ga." multiplied by 1.5 is less than the number on Chart 1.2 to use the number on chart 1.2. It doesn't seem to be working for all of the cells. Did I do something wrong in the formula? I know this sounds very confusing so I included the workbook so you could see the IF function. It works for most of the cells, but not all of them.
    Attached Files Attached Files
    Last edited by Zimmy242; 07-28-2023 at 01:06 PM.

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,863

    Re: IF Function is not returning correct number for all cells

    I don't see anything syntactically wrong with the formula. Can you identify a few cells where you think the formula is returning an incorrect result?

    If I knew which cells to debug, I would probably start debugging by bringing up the Evaluate formula tool (https://support.microsoft.com/en-us/...rs=en-us&ad=us ) and step through the function, checking each step to make sure it is doing exactly what I expect it to do.

    Gut instinct is that the problem is going to turn out to be some kind of rounding or floating point error, where a calculation that you think should return TRUE is actually returning FALSE (or vice-versa). If it does end up being some kind of rounding or floating point error, the solution will depend on exactly what you are expecting.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Registered User
    Join Date
    08-24-2021
    Location
    Minnesota
    MS-Off Ver
    365
    Posts
    33

    Re: IF Function is not returning correct number for all cells

    Cells B67, B68, B69, C67, C68, C69 (basically all of $118.38), E66

  4. #4
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,465

    Re: IF Function is not returning correct number for all cells

    The value of Cell B67 is correct: It is '20 Ga.'!B18*1.5 = $78.92 * 1.5 = $118.38

  5. #5
    Registered User
    Join Date
    08-24-2021
    Location
    Minnesota
    MS-Off Ver
    365
    Posts
    33

    Re: IF Function is not returning correct number for all cells

    But that is lower than B18, so it should show $118.40.

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,863

    Re: IF Function is not returning correct number for all cells

    First, I note the external references that make it impossible to test the calculations. I assumed that the external references should be to this workbook, and delete the external references from the formulas. I did not do anything else to try to verify if this resulted in the correct references. With that edit, follow along in the Evaluate formula tool, if you like.

    B67:
    1) Retrieve value from 20 Ga.!B21 -- 79.89
    2) multiply that by 1.5 -- 119.835
    3) retrieve value from 18 Ga.!B18 -- 118.4
    4) compare step 2 to step 3. step 2 is larger than step 3, so proceed to value_if_false argument
    5) retrieve value from 20 Ga.!B18 -- 78.92
    6) multiply by 1.5 and return final result -- 118.38

    C68:
    1) Retrieve value from 20 Ga.!C22 -- 83.15
    2) multiply by 1.5 -- 124.725
    3) retrieve value from 18 Ga.!C19 -- 118.4
    4) compare step 2 to step 3. step 2 is larger than step 3, so proceed to value_if_false argument
    5) retrieve value from 20 Ga.!C19 -- 78.92
    6) multiply by 1.5 and return final result -- 118.38

    That's how 2 of those cells are calculating. Which step is doing something you are not expecting?

  7. #7
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,465

    Re: IF Function is not returning correct number for all cells

    The formula of cell B67 is

    =IF('20 Ga.'!B21*1.5<'18 Ga.'!B18,'18 Ga.'!B18,'20 Ga.'!B18*1.5)

    I think that should be

    =IF('20 Ga.'!B18*1.5<'18 Ga.'!B18,'18 Ga.'!B18,'20 Ga.'!B18*1.5)

  8. #8
    Registered User
    Join Date
    08-24-2021
    Location
    Minnesota
    MS-Off Ver
    365
    Posts
    33

    Re: IF Function is not returning correct number for all cells

    OMG!! You're right. I feel really dumb now, but I didn't notice that the first part of the function was attaching to the wrong cell.

  9. #9
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,465

    Re: IF Function is not returning correct number for all cells

    You are Welcome.

    It doesn't matter.
    This happens to everyone who works with Excel or something similar.

    Glad to have helped.

    TIP: If a formula returns an unexpected result you can evaluate the formula:
    Go to the formula and click Formulas --> Evaluate Formula --> Evaluate --> Evaluate ....
    Last edited by HansDouwe; 07-28-2023 at 01:13 PM.

+ 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] Sum Function not returning the correct answer
    By Johnnog in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 02-20-2023, 09:50 AM
  2. Distance Function Not Returning Correct Figure
    By Megatron01 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-06-2020, 08:12 PM
  3. Lookup function not returning the correct values
    By bvijay65 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-24-2019, 08:05 AM
  4. [SOLVED] SUM function not returning correct result
    By rayted in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-26-2018, 11:04 AM
  5. [SOLVED] Averageifs function not returning correct average
    By CSherman in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-02-2017, 11:11 PM
  6. Indirect function not returning correct value
    By iamskippy in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 09-16-2013, 04:28 PM
  7. [SOLVED] MAX Function not returning correct value
    By Phil in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-28-2006, 05: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