Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Highlighted
Not applicable

How to create Age range

Hi all,

I have project to analyze my member age with range.

Can you guys help me on this.

Example

NameAge
Soehoed14
Saulina12
Murni17
Lina19
Togu22
Tan23
Sunarti20
Nyoman16
Daswirman30
Asnaria32
Mrtha35
Yen28
Fatimah40
Retno45
Darwadi34
Maemunah52
Florentina55
Andi65
Halena43
Susilowati36
Elizabet24
Isnaniek27
Asliani18
Darwati51
Nurdin48
Ambo41
Lankoani36

I want to create range :

How many :

<17 years

17 - 25

25 - 30

30 - 40

40 - 50

> 50

Thank you

Henry

Tags (1)
1 Solution

Accepted Solutions
MVP
MVP

Re: How to create Age range

Create below field in your script..

If(Age <=17, '<17 Years',

  IF(Age >= 17 and Age < 25, '17 - 25',

  IF(Age >= 25 and Age < 30, '25 - 30',

  IF(Age >= 30 and Age < 40, '30 - 40',

  IF(Age >= 40 and Age < 50, '40 - 50',

  '50+'))))) as AgeRange

Now create a chart

Dimension

AgeRange

Expression

COUNT(Distinct Name)

6 Replies
MVP
MVP

Re: How to create Age range

Create below field in your script..

If(Age <=17, '<17 Years',

  IF(Age >= 17 and Age < 25, '17 - 25',

  IF(Age >= 25 and Age < 30, '25 - 30',

  IF(Age >= 30 and Age < 40, '30 - 40',

  IF(Age >= 40 and Age < 50, '40 - 50',

  '50+'))))) as AgeRange

Now create a chart

Dimension

AgeRange

Expression

COUNT(Distinct Name)

MVP
MVP

Re: How to create Age range

If you dont want to create the same in script... use below as a calculated dimension and use the same expression provided above.

=Aggr(If(Age <=17, '<17 Years',

  IF(Age >= 17 and Age < 25, '17 - 25',

  IF(Age >= 25 and Age < 30, '25 - 30',

  IF(Age >= 30 and Age < 40, '30 - 40',

  IF(Age >= 40 and Age < 50, '40 - 50',

  '50+'))))),Name)

Not applicable

Re: How to create Age range

Manish's solution is good. You can also uses intervalmatch(), where you load inline the ranges

For example:

Employee_age:
LOAD * INLINE [
Name, Age
John, 35
Katy, 26
William, 52
Barbara, 46
Erik, 18
]
;



Age:
LOAD *
INLINE [
MinAge, MaxAge
0, 17
18, 25
26, 30
31, 40
41, 50
51, 1000
]
;


IntervalMatch (Age)
Load
MinAge as Min_Age, /*------Rename to avoid synthetic keys---------*/
MaxAge as Max_Age
Resident
Age;

Put the appropriate fields in a straight table for e.g. :

I hope it helped!

Best,

T

Not applicable

Re: How to create Age range

Somehow the picture from my straight table disappeared, but I think you don't need to see it to get the point.

Best,

T

Not applicable

Re: How to create Age range

I think Class Function might you to achieve it..

=class(Age,5) ,it groups Age as class with difference of 5

Best Regards,

Govindaraj

drcater1413
New Contributor II

Re: How to create Age range

Hi Manish,

I am trying to show the range by low to high grouping, but get a scattered bars.

If(score <=590, 'LT 590',

  IF(score >= 590 and score < 620, '590 - 620',

  IF(score >= 620 and score < 640, '620 - 640',

  IF(score >= 640 and score < 680, '640 - 680',

  IF(score >= 680 and score < 699, '680 - 699',

  '700+')))))

I want to start with LT590 then 590-620, etc.  Any suggestions.

pic.PNG