Results 1 to 5 of 5
  1. #1
    Costa is offline Novice
    Windows 7 Access 2007
    Join Date
    Feb 2010
    Posts
    13

    Sum results give me negative values !

    Hello all

    I have a field named (Location) with 5 entries (A,B,C,D,E)

    I used this formula to calculate the sum of all records that have a certain entry ..

    =Sum([Location]="A") , To give me all the records that contains "A" as an entry .. The formula work fine but the results are comes up with a minus next to them !!! Like Sum= -8 !! Why it gives me the results in minus ?



    Is there anyway to remove this minus sign?

    Is my formula Ok to get the information I want ?

    Thanks all

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Because True is represented by -1. Try this:

    =Sum(IIf([Location]="A", 1, 0))

    You could also use the Abs() function around what you have now, but this will be more useful in the long run.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Costa is offline Novice
    Windows 7 Access 2007
    Join Date
    Feb 2010
    Posts
    13
    Quote Originally Posted by pbaldy View Post
    Because True is represented by -1. Try this:

    =Sum(IIf([Location]="A", 1, 0))

    You could also use the Abs() function around what you have now, but this will be more useful in the long run.

    Thanks mate for the help ..

    I have another question, I want to edit the formula to get the sum of Location fields with "A" or "B" entries together in one result ?

    I tried : =Sum(IIf([Location]="A" Or "B")) but didn't work !!!

    any idea ?

    Thanks again

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You have to repeat the field, just like in SQL:

    [Location]="A" Or [Location]="B"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Costa is offline Novice
    Windows 7 Access 2007
    Join Date
    Feb 2010
    Posts
    13
    Quote Originally Posted by pbaldy View Post
    You have to repeat the field, just like in SQL:

    [Location]="A" Or [Location]="B"

    Thanks for the help .. worked fine

Please reply to this thread with any new information or opinions.

Similar Threads

  1. (simple) Expressions give error message
    By P.Hofman in forum Forms
    Replies: 3
    Last Post: 01-21-2010, 01:57 AM
  2. Replies: 2
    Last Post: 01-13-2010, 05:29 AM
  3. Convert Negative Values to Positive
    By creativefusion in forum Queries
    Replies: 1
    Last Post: 10-21-2009, 02:47 AM
  4. Replies: 1
    Last Post: 10-05-2009, 06:52 AM
  5. Get the sum of decimal values - weird results
    By BengtCarlsson in forum Queries
    Replies: 2
    Last Post: 02-10-2006, 04:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums