If Statement Possible? (1 Viewer)

fletchee2003

Registered User.
Local time
Today, 00:52
Joined
Apr 21, 2005
Messages
31
What I am trying to figure out is how to sum a field/column based on the answer from another field/column. Specifically, I have a yes/no field with numeric values in the next field. I want to sum the values of only the fields that are associated with yes. My current formula sums all values regardless of yes or no. So if i check yes next to product 1 at $5, no next to product 2 at $7 and yes next to product 3 at $3, I need a formula that would return the result of $8 and not $15. Any suggestions would be greatly appreciated.
Thank you.
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 22:52
Joined
Aug 30, 2003
Messages
36,133
=Sum(IIf(YesNoField = True, AmountField, 0))
 

boblarson

Smeghead
Local time
Yesterday, 22:52
Joined
Jan 12, 2001
Messages
32,059
You can have a text box on your report that has this as it's control source

=SUM(IIf([YourYesNoFieldNameHere]=True,Nz([YourFieldYouWantToSumHere],0),0))
 

fletchee2003

Registered User.
Local time
Today, 00:52
Joined
Apr 21, 2005
Messages
31
Thank you!!!

I tried both and they worked perfectly, Thank you.
 

boblarson

Smeghead
Local time
Yesterday, 22:52
Joined
Jan 12, 2001
Messages
32,059
I tried both and they worked perfectly, Thank you.

Glad to hear. Just a quick explanation of what was different in mine than in Pauls. In mine I just made sure to deal with potential nulls so that they wouldn't cause a problem, if you had any.
 

Users who are viewing this thread

Top Bottom