Adding up the number of instances.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I Need an expression that will count up the Number of times "10" appears.
Right now I'm Using; =IIf( 'field a'=10,1,0)+ IFF('field b'=10,1,0+.....
This is a little cumbersom. Is there an expression that does this?
 
If your fields always contain a value then
Abs([FieldA]=10 + [FieldB]=10 + [FieldC]=10 + ...)

If your fields could contain NULL then this gets more complex.
Abs(NZ([FieldA],0)=10 + Nz([FieldB],0)=10 + Nz([FieldC],0)=10 + ...)

The need to do this suggests that your design is not optimal and that the
fields you are checking should end up as rows in a separate table where you
could do something much simpler.
 
Thank You for the Re

This is a little better. I wiish there was an expression; Expr([field
a][field b].....=10) this would be useful at times and much easier to type
in when it was needed.
Also, why can't I cut and paste when I'm in build mode?




John Spencer said:
If your fields always contain a value then
Abs([FieldA]=10 + [FieldB]=10 + [FieldC]=10 + ...)

If your fields could contain NULL then this gets more complex.
Abs(NZ([FieldA],0)=10 + Nz([FieldB],0)=10 + Nz([FieldC],0)=10 + ...)

The need to do this suggests that your design is not optimal and that the
fields you are checking should end up as rows in a separate table where you
could do something much simpler.

domdog said:
I Need an expression that will count up the Number of times "10" appears.
Right now I'm Using; =IIf( 'field a'=10,1,0)+ IFF('field b'=10,1,0+.....
This is a little cumbersom. Is there an expression that does this?
 
When you are in build mode you are in a dialog box. You can cut and paste
by using Control + X to cut and Control + V to Paste and Control + C to
copy. You can't use the menus since you are in dialog mode.

Your problem is that your table is probably not designed correctly for
Access. Probably a good spreadsheet design.

You should have a table that is joined to your current table. The new table
would have three fields (or maybe more)
FieldID: which holds the value that is in your current table that uniquely
identifies the row.
Field2: The name of your current fields to identify the type of information
(for example, Jan, Feb, Mar, Apr, May, etc)
Field3: The value in your current fields

Then to get the sum ifor each of your current rows, your query would look
something like

SELECT FieldID, Abs(Sum(Field3=10)) as CountTens
FROM theNewTable


domdog said:
Thank You for the Re

This is a little better. I wiish there was an expression; Expr([field
a][field b].....=10) this would be useful at times and much easier to
type
in when it was needed.
Also, why can't I cut and paste when I'm in build mode?




John Spencer said:
If your fields always contain a value then
Abs([FieldA]=10 + [FieldB]=10 + [FieldC]=10 + ...)

If your fields could contain NULL then this gets more complex.
Abs(NZ([FieldA],0)=10 + Nz([FieldB],0)=10 + Nz([FieldC],0)=10 + ...)

The need to do this suggests that your design is not optimal and that the
fields you are checking should end up as rows in a separate table where
you
could do something much simpler.

domdog said:
I Need an expression that will count up the Number of times "10"
appears.
Right now I'm Using; =IIf( 'field a'=10,1,0)+ IFF('field
b'=10,1,0+.....
This is a little cumbersom. Is there an expression that does this?
 
John Spencer said:
When you are in build mode you are in a dialog box. You can cut and paste
by using Control + X to cut and Control + V to Paste and Control + C to
copy. You can't use the menus since you are in dialog mode.

Your problem is that your table is probably not designed correctly for
Access. Probably a good spreadsheet design.

You should have a table that is joined to your current table. The new table
would have three fields (or maybe more)
FieldID: which holds the value that is in your current table that uniquely
identifies the row.
Field2: The name of your current fields to identify the type of information
(for example, Jan, Feb, Mar, Apr, May, etc)
Field3: The value in your current fields

Then to get the sum ifor each of your current rows, your query would look
something like

SELECT FieldID, Abs(Sum(Field3=10)) as CountTens
FROM theNewTable


domdog said:
Thank You for the Re

This is a little better. I wiish there was an expression; Expr([field
a][field b].....=10) this would be useful at times and much easier to
type
in when it was needed.
Also, why can't I cut and paste when I'm in build mode?




John Spencer said:
If your fields always contain a value then
Abs([FieldA]=10 + [FieldB]=10 + [FieldC]=10 + ...)

If your fields could contain NULL then this gets more complex.
Abs(NZ([FieldA],0)=10 + Nz([FieldB],0)=10 + Nz([FieldC],0)=10 + ...)

The need to do this suggests that your design is not optimal and that the
fields you are checking should end up as rows in a separate table where
you
could do something much simpler.

I Need an expression that will count up the Number of times "10"
appears.
Right now I'm Using; =IIf( 'field a'=10,1,0)+ IFF('field
b'=10,1,0+.....
This is a little cumbersom. Is there an expression that does this?
 
Back
Top