If the IIf condition is true then Sum adds a 1, it the
condition is false then it adds 0 so the total is the count
of records meeting the condition.
There are many ways of doing this kind of thing. This one
is more efficient but also more obscure:
=-Sum([Warranty Income] => 0 And [New / Used] = "New") /
-Sum([New / Used] = "New")
or a little less efficient and possibly less obscure:
=Abs(Sum([Warranty Income] => 0 And [New / Used] = "New"))
/ Abs(Sum([New / Used] = "New"))
or this one is about the same efficiency as the
Sun(IIf(...)) I suggested you use:
=Count(IIf([Warranty Income] => 0 And [New / Used] =
"New", 1,Null)) / Count(IIf([New / Used] = "New", 1, Null))
--
Marsh
MVP [MS Access]
That worked. Thank you. Just a quick question if you don't mind. What do
the "1,0" represent at the end of those expressions? Thanks again....
Marshall Barton said:
Reese said:
Sorry. The 3 fields in the expression are: "Warranty Income" which contains
currency value; "New / Used" which is either new or used; And then to divide
by the number of "new" returns in the "New / Used" field. Here is the
formula that I wrote based on your suggestion:
=Sum(IIf([Warranty Income] => 0 And [New / Used] = "New", 1, 0)) /
sum(IIf([New / Used] = "New", 1, 0))
Sorry, I had an extra = sign in there. It was supposed to
be:
=Sum(IIf([Warranty Income] > 0 And [New / Used] = "New", 1,
0)) / Sum(IIf([New / Used] = "New", 1, 0))