Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
santho_ak
Partner - Creator III
Partner - Creator III

Create age from Year of Birth in Qliksense

1. In my table, I have only year of Birth. I need to calculate the age. Can some one help me.

2. Also, I need to group the age like 0>35, 35-45, 50-60 in a bar chart.

Help me out.

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Clever Anjos suggested a LOAD script solution, which is recommended.

If you want to use the expressions in a chart, remove the 'as Age'

    =Age(Today(), MakeDate(BirthYear))

(and use this as calculated dimension?)

What is the measure of your chart?

View solution in original post

8 Replies
Clever_Anjos
Employee
Employee

Create these fields into your script


1  - Age(Today(), MakeDate(youryearbirth)) as Age

2 - Using this field

     If( Age < =35, '0>35',

     If(Age <= 45,'35-45', '50-60')) as AgeBin

eduardo_dimperio
Specialist II
Specialist II

Try use Interval()

1 - Interval( Today()-BirthAge, 'D' ) /365 AS Age

2-

If( Age < =35, '0>35',

If(Age <= 45,'35-45', '50-60')) as Range

santho_ak
Partner - Creator III
Partner - Creator III
Author

Its not working. My field name is BirthYear. So I tried it. It says error in expression.

Age(Today(), MakeDate(BirthYear)) as Age

Even I tried,

Age(Today(), MakeDate[BirthYear]) as Age

cleveranjos

santho_ak
Partner - Creator III
Partner - Creator III
Author

Hi,

   Sry its not working. This is the script I tried out

Interval( Today()-BirthYear, 'D' ) /365 AS Age

Anonymous
Not applicable

This expression is certainly correct and must work

Age(Today(), MakeDate(BirthYear)) as Age


Something you're are not telling...  What are the values of the BirthYear field?

swuehl
MVP
MVP

Clever Anjos suggested a LOAD script solution, which is recommended.

If you want to use the expressions in a chart, remove the 'as Age'

    =Age(Today(), MakeDate(BirthYear))

(and use this as calculated dimension?)

What is the measure of your chart?

santho_ak
Partner - Creator III
Partner - Creator III
Author

Thanks Stefan, its working. Am using Emp ID as measure, so that I can find the age of a particular employee in my table. Is it fine.

I need help in grouping the ages. Help me out.

swuehl
MVP
MVP

Are you really using Emp ID as measure? That's kind of unusual, I would have used Emp ID as dimension and the age as measure, if you want to show the age per emp.

If you want to group by the age and show for example how many emps are in this age range, use something like

= If( Age < =35, '0>35',

     If(Age <= 45,'35-45', '50-60'))

as calculated dimension and

=Count(DISTINCT [Emp ID])

as measure.

Buckets