Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help - count function

Status
Not open for further replies.

abc567

Programmer
Jul 8, 2009
45
US
Hi,
I have a report with parameter named status.
Database has status values as 'c' and 'x' only.

I want to count the number of records selected with respective status.

For example if there are 20 records with status value 'c' and 30 records with status value 'x'

And if i select parameter as 'c' then count the number of records with that status 'c' i.e. it should be 20.
If i select parameter as 'x' then count the number of records with that status 'x' i.e. it should be 30.

I would really appreciate your help..

Thanks
 
Set up a dynamic parameter (%Par) and in your select statement do this: Table.Field=%Par.

The users will then be asked to select from the values of the desired field. (a 'c' or 'x' in your example)

you can then use a summary of Table.Field placed in the report footer to perform a count on the returned records.



 
I have been told to use static parameters. So an alternate solution to this will be good.
 
You should be able to use a static parameter instead of the dynamic and manually enter into the parameter list the 2 values you need.
 
I already tried that . But of no use..
To be more clear .. I have multiple static prompts
First prompt is 'status'
second is 'Type' and third is 'branch'

If i selected status as 'X', type as 'ALL' and branch as 'ALL' then the summary value i.e., count(ID) is giving 25.
If i selected status as 'C', type as 'ALL' and branch as 'ALL' then the summary value i.e., count(ID) is giving me the same value 25. However database doesnt have any records with status 'C'.
 
can you show more details please.

are you using record selection formulas with parameters to narrow the the status to the item selected ('X' or 'C') (ie: TABLE.StatusField=%Par)

You could try formulas to evaluate the status then assign a value.
@StatusX = IF ({TABLE.StatusField}="X") then 1 else 0
@StatusC = IF ({TABLE.StatusField}= "C") then 1 else 0
and then SUM each status indivdually.


There is likely an easier way, but this is what came to mind first on a low caffeine day!
 
It worked but looking for easiest approach..

Thanks fisheromacse.. you saved my day..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top