Find the age of the people

Hello friends,

I am new to Cognos. I have a requirement to find the number of people who are at different ages

for ex:

No-of people who are bteween Age0-2, No-of people who areAge 3

How can i creat this kind of report? Whether i should make any changes in the model in FM

Please need ur inputs

Hi Sandy,
In the published package that you’ll be using to create the report, is there simply a column with the person’s age? If so, you’ll need to create the ‘buckets’ using a CASE statement. Are you familiar with those?

If the package already has the age buckets set up, then all you’ll need to do is drag in the column, along with whatever other columns you need, group the list by the age bucket column and then perform a count on that column. Perform the count by adding a data item in the query for which the expression is simply count(age_bucket).

Hope this helps.

Thank u . i not aware of bucket concepts. I dont have a age column ,but i calculated the age column using the birthdate.

Hi Sandy,
To put the ages in buckets you would need to use a CASE statement to ‘calculate’ the buckets. It would look something like this:

CASE WHEN age_column between 1 and 3 THEN 'Age 1 - 3' WHEN age_column between 4 and 6 THEN 'Age 4 - 6' WHEN age_column between 7 and 12 THEN 'Age 7 - 12' ELSE 'Other' END

If your age column is character rather than integer, you’ll need to put single quotes around the actual ages. For example: age_column between ‘1’ and ‘3’

[quote=“Jeff Robinson, post:4, topic:713”]Hi Sandy,
To put the ages in buckets you would need to use a CASE statement to ‘calculate’ the buckets. It would look something like this:

CASE WHEN age_column between 1 and 3 THEN 'Age 1 - 3' WHEN age_column between 4 and 6 THEN 'Age 4 - 6' WHEN age_column between 7 and 12 THEN 'Age 7 - 12' ELSE 'Other' END

Thanks for the code…After the buckets are created , should i create the data item Age1-3 and Age4 -6

but how to find the count of the people who are at ages 1and 3 and so on

i am planning to prepare a cross tab. I should have the report like this

Age 1-3 |Age 4-6|

   x   |   y

If your age column is character rather than integer, you’ll need to put single quotes around the actual ages. For example: age_column between ‘1’ and ‘3’[/quote]

You’re welcome.

To make a crosstab, first create that data item that I mentioned earlier using the expression count(age_bucket). Then drag the age_bucket to the columns area, the count into the measure area, and whatever field you want to use for rows.

i am getting a parse error in the expression

if _years_between(currentdate,birthdate) between 0 and 3 then Age 0-3

any idea?

even if i use the case i get the same error

Yes, Age 0 - 3 will need to be in quotes e.g. ‘Age 0 - 3’