Count the number of times something shows up

  • Thread starter Thread starter AccessDB
  • Start date Start date
A

AccessDB

On my report I have a textbox that is supppose to count how many times
a "engine shows up on the report. My code for the textbox is:
=Count([Engine Manufacturer]="BS")

But instead of just giving me the count of "BS", it give me the count
of the whole column. How or what should I do to make it do what I want
it to do.
 
On my report I have a textbox that is supppose to count how many times
a "engine shows up on the report. My code for the textbox is:
=Count([Engine Manufacturer]="BS")

But instead of just giving me the count of "BS", it give me the count
of the whole column. How or what should I do to make it do what I want
it to do.

=Sum(IIf([Engine Manufacturer] = "BS",1,0))
 
Your expression [Engine Manufacturer]="BS" returns either -1/True or 0/False.
Each of these possible values is counted exactly the same.
To count the true expressions, try:
=Sum(Abs([Engine Manufacturer]="BS"))
 
Your expression [Engine Manufacturer]="BS" returns either -1/True or 0/False.
Each of these possible values is counted exactly the same.
To count the true expressions, try:
=Sum(Abs([Engine Manufacturer]="BS"))
--
Duane Hookom
Microsoft Access MVP



AccessDB said:
On my report I have a textbox that is supppose to count how many times
a "engine shows up on the report. My code for the textbox is:
=Count([Engine Manufacturer]="BS")
But instead of just giving me the count of "BS", it give me the count
of the whole column. How or what should I do to make it do what I want
it to do.- Hide quoted text -

- Show quoted text -

Thank you very much.

No to go futher, what's the code so I can find out the percentage of
"BS"
Example: now with you code it shows 128 (which is correct), but now I
also want the percentage. The grand total number is 281. And with out
coding that would be 45%. What is the code that is needed here.
 
Your expression [Engine Manufacturer]="BS" returns either -1/True or 0/False.
Each of these possible values is counted exactly the same.
To count the true expressions, try:
=Sum(Abs([Engine Manufacturer]="BS"))
AccessDB said:
On my report I have a textbox that is supppose to count how many times
a "engine shows up on the report. My code for the textbox is:
=Count([Engine Manufacturer]="BS")
But instead of just giving me the count of "BS", it give me the count
of the whole column. How or what should I do to make it do what I want
it to do.- Hide quoted text -
- Show quoted text -

Thank you very much.

No to go futher, what's the code so I can find out the percentage of
"BS"
Example: now with you code it shows 128 (which is correct), but now I
also want the percentage. The grand total number is 281. And with out
coding that would be 45%. What is the code that is needed here.- Hide quoted text -

- Show quoted text -

I meant to say that I want ot to find out the percentage of "BS" which
is 128 out of 281. But I need to code for this so I can put it in the
textbox property control source. Sorry for the inconvience and thank
you for all the help.
 
On Feb 16, 3:58 pm, Duane Hookom <duanehookom@NO_SPAMhotmail.com>
wrote:
Your expression [Engine Manufacturer]="BS" returns either -1/True or 0/False.
Each of these possible values is counted exactly the same.
To count the true expressions, try:
=Sum(Abs([Engine Manufacturer]="BS"))
--
Duane Hookom
Microsoft Access MVP
:
On my report I have a textbox that is supppose to count how many times
a "engine shows up on the report. My code for the textbox is:
=Count([Engine Manufacturer]="BS")
But instead of just giving me the count of "BS", it give me the count
of the whole column. How or what should I do to make it do what I want
it to do.- Hide quoted text -
- Show quoted text -
Thank you very much.
No to go futher, what's the code so I can find out the percentage of
"BS"
Example: now with you code it shows 128 (which is correct), but now I
also want the percentage. The grand total number is 281. And with out
coding that would be 45%. What is the code that is needed here.- Hide quoted text -
- Show quoted text -

I meant to say that I want ot to find out the percentage of "BS" which
is 128 out of 281. But I need to code for this so I can put it in the
textbox property control source. Sorry for the inconvience and thank
you for all the help.- Hide quoted text -

- Show quoted text -

I used =Sum(Abs([Engine Manufacturer]="BS")) and got the answer I
needed. Now I need to get the percentage of "BS" in the column. This
table has 281 rows and 128 of it is "BS". I know how to do the math,
but I don't know how to write to code into my textbox - property -
control source. Can you please help me. Thank you.
 
On Feb 16, 3:58 pm, Duane Hookom <duanehookom@NO_SPAMhotmail.com>
wrote:
Your expression [Engine Manufacturer]="BS" returns either -1/True or 0/False.
Each of these possible values is counted exactly the same.
To count the true expressions, try:
=Sum(Abs([Engine Manufacturer]="BS"))
:
On my report I have a textbox that is supppose to count how many times
a "engine shows up on the report. My code for the textbox is:
=Count([Engine Manufacturer]="BS")
But instead of just giving me the count of "BS", it give me the count
of the whole column. How or what should I do to make it do what I want
it to do.- Hide quoted text -
- Show quoted text -
Thank you very much.
No to go futher, what's the code so I can find out the percentage of
"BS"
Example: now with you code it shows 128 (which is correct), but now I
also want the percentage. The grand total number is 281. And with out
coding that would be 45%. What is the code that is needed here.- Hide quoted text -
- Show quoted text -

I meant to say that I want ot to find out the percentage of "BS" which
is 128 out of 281. But I need to code for this so I can put it in the
textbox property control source. Sorry for the inconvience and thank
you for all the help.- Hide quoted text -

- Show quoted text -

I used =Sum(Abs([Engine Manufacturer]="BS")) and got the answer I
needed. Now I need to get the percentage of "BS" in the column. This
table has 281 rows and 128 of it is "BS". I know how to do the math,
but I don't know how to write to code into my textbox - property -
control source. Can you please help me. Thank you.

=Sum(Abs([Engine Manufacturer]="BS"))/Count("*")
 
On Feb 16, 3:58 pm, Duane Hookom <duanehookom@NO_SPAMhotmail.com>
wrote:
Your expression [Engine Manufacturer]="BS" returns either -1/True or 0/False.
Each of these possible values is counted exactly the same.
To count the true expressions, try:
=Sum(Abs([Engine Manufacturer]="BS"))
--
Duane Hookom
Microsoft Access MVP
:
On my report I have a textbox that is supppose to count how many times
a "engine shows up on the report. My code for the textbox is:
=Count([Engine Manufacturer]="BS")
But instead of just giving me the count of "BS", it give me the count
of the whole column. How or what should I do to make it do what I want
it to do.- Hide quoted text -
- Show quoted text -
Thank you very much.
No to go futher, what's the code so I can find out the percentage of
"BS"
Example: now with you code it shows 128 (which is correct), but now I
also want the percentage. The grand total number is 281. And with out
coding that would be 45%. What is the code that is needed here.- Hide quoted text -
- Show quoted text -
I meant to say that I want ot to find out the percentage of "BS" which
is 128 out of 281. But I need to code for this so I can put it in the
textbox property control source. Sorry for the inconvience and thank
you for all the help.- Hide quoted text -
- Show quoted text -
I used =Sum(Abs([Engine Manufacturer]="BS")) and got the answer I
needed. Now I need to get the percentage of "BS" in the column. This
table has 281 rows and 128 of it is "BS". I know how to do the math,
but I don't know how to write to code into my textbox - property -
control source. Can you please help me. Thank you.

=Sum(Abs([Engine Manufacturer]="BS"))/Count("*")
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail- Hide quoted text -

- Show quoted text -

Thank you. It did what I wanted it to do. Again thank you very much. I
hope that you can help me in the future.
 
AccessDB said:
On my report I have a textbox that is supppose to count how many times
a "engine shows up on the report. My code for the textbox is:
=Count([Engine Manufacturer]="BS")

But instead of just giving me the count of "BS", it give me the count
of the whole column. How or what should I do to make it do what I want
it to do.


Count counts all non-Null values and neither True nor False
is Null.

Any of these will do what you want:

= -Sum([Engine Manufacturer]="BS")
or
=Sum(IIf([Engine Manufacturer]="BS", 1, 0))
or
=Count(IIf([Engine Manufacturer]="BS", 1, Null))
 
Back
Top