Results 1 to 5 of 5

Thread: Equation

  1. #1
    Join Date
    May 2004
    Posts
    7

    Unanswered: Equation

    any idea why this equation doesnt work?

    =nz([1stTotal],0)+nz([2ndTotal],0)+nz([3rdTotal],0)/100*nz([Discount],0)

    cant figure it out !

    thank you

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    What exactly do you mean by not working? Is it throwing an error message or are you not getting the result you were expecting? I'm guessing it's the latter, this would be caused by order of operations.

    Add some parenthesis around your criteria:
    =nz(([1stTotal],0)+nz([2ndTotal],0)+nz([3rdTotal],0))/(100*nz([Discount],0))

    Right now, Access will read the formula as:

    =nz([1stTotal],0)+nz([2ndTotal],0)+(nz([3rdTotal],0/100))*nz([Discount],0)
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    May 2004
    Posts
    7
    ah right well i wanted to add my totals 1,2,3, then divide that figure by 100 then times that by the amount shown in discount?

    and by not working i mean the answer isnt correct

    thank you

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    The first example I showed you should be effective.

    It's a simple order of operations rule. Multiplication and division will always be executed before addition, therefore, the reason you are not getting the value you expect is because access is preforming all of the multiplication and division, THEN the addition. By adding the paranthesis, you are explicitly telling access that you would like to add the first three values, THEN do the division. Try it out.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  5. #5
    Join Date
    Apr 2004
    Location
    Sydney Australia
    Posts
    369
    ah right well i wanted to add my totals 1,2,3, then divide that figure by 100 then times that by the amount shown in discount?

    (1+2+3)/100*Whatever

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •