Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

When I sum my YES's they are giving me a negative

Status
Not open for further replies.

ferrisj

IS-IT--Management
Dec 7, 2004
79
US
I am using this expression to sum my boolean yes values

Sum(Abs([FIELD])=True)

It gives me a negative number, but i would like it not to show a negative. how do i fix this?
 

Hi,

How about

sum(iif([Field],1,0))

Skip,

[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue]
 
Just switch it around a bit
Sum(Abs([FIELD]=True))

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Counting the values will always count all non-null values (True and False). I expect ferrisj only wanted to count the True values.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Why not simply this ?
Sum(Abs([FIELD]))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Although Sum(Abs([Field])) should work as well, I usually like to include the =True as a "self-documenting" feature. It reminds me that [Field] is a true/false yes/no expression.

In this case, I left it in since the original posting used it.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
I didn't notice any mention of a "where clause" in your ealier reply.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top