Counting in a report

  • Thread starter Thread starter Allison
  • Start date Start date
A

Allison

I am creating a report from a table and am trying to
create an expression for a conditional count. For
example, I have a Yes/No field, and I just want to count
all of the Yes occurences.

I know that I can create a query and get the results that
I want, I can also do this is a subreport, and I know that
I can use =sum and rely on the -1 and 0 values of the
Yes/No field to come up with the result.

It just seems to me that I should be able to use iif and
count together in an expression to get the results that I
want. Can I??????? Thanks so much.
 
To count the Yes values in the report footer, add a text box with a control
source of:
=Sum(Abs([YourYNField]))
There is no need to confuse the expression with IIf() syntax.
 
Duane: Thanks for your help, but can I use IIf() to do a
conditional count on a report? Allison
-----Original Message-----
To count the Yes values in the report footer, add a text box with a control
source of:
=Sum(Abs([YourYNField]))
There is no need to confuse the expression with IIf() syntax.

--
Duane Hookom
MS Access MVP


I am creating a report from a table and am trying to
create an expression for a conditional count. For
example, I have a Yes/No field, and I just want to count
all of the Yes occurences.

I know that I can create a query and get the results that
I want, I can also do this is a subreport, and I know that
I can use =sum and rely on the -1 and 0 values of the
Yes/No field to come up with the result.

It just seems to me that I should be able to use iif and
count together in an expression to get the results that I
want. Can I??????? Thanks so much.


.
 
Certainly:
=Sum(IIf(<a true false expresssion>, 1, 0))
This is a little more typing but the result should be the same.
--
Duane Hookom
MS Access MVP


Allison said:
Duane: Thanks for your help, but can I use IIf() to do a
conditional count on a report? Allison
-----Original Message-----
To count the Yes values in the report footer, add a text box with a control
source of:
=Sum(Abs([YourYNField]))
There is no need to confuse the expression with IIf() syntax.

--
Duane Hookom
MS Access MVP


I am creating a report from a table and am trying to
create an expression for a conditional count. For
example, I have a Yes/No field, and I just want to count
all of the Yes occurences.

I know that I can create a query and get the results that
I want, I can also do this is a subreport, and I know that
I can use =sum and rely on the -1 and 0 values of the
Yes/No field to come up with the result.

It just seems to me that I should be able to use iif and
count together in an expression to get the results that I
want. Can I??????? Thanks so much.


.
 
Well, if you insist

=Count(IIF(YesNoField = True, 1, Null))

Count counts all non-null values. If a value is anything other than null, then
count increments by one.



Duane said:
Certainly:
=Sum(IIf(<a true false expresssion>, 1, 0))
This is a little more typing but the result should be the same.
--
Duane Hookom
MS Access MVP

Allison said:
Duane: Thanks for your help, but can I use IIf() to do a
conditional count on a report? Allison
-----Original Message-----
To count the Yes values in the report footer, add a text box with a control
source of:
=Sum(Abs([YourYNField]))
There is no need to confuse the expression with IIf() syntax.

--
Duane Hookom
MS Access MVP


I am creating a report from a table and am trying to
create an expression for a conditional count. For
example, I have a Yes/No field, and I just want to count
all of the Yes occurences.

I know that I can create a query and get the results that
I want, I can also do this is a subreport, and I know that
I can use =sum and rely on the -1 and 0 values of the
Yes/No field to come up with the result.

It just seems to me that I should be able to use iif and
count together in an expression to get the results that I
want. Can I??????? Thanks so much.


.
 
Back
Top