Qlik Community

Ask a Question

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Our May 2021 end-to-end product release from Data Integration to Data Analytics is out! READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
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

1 Solution

Accepted Solutions
MK_QSL
MVP
MVP

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)

View solution in original post

10 Replies
MK_QSL
MVP
MVP

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)

View solution in original post

MK_QSL
MVP
MVP

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
Author

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
Author

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
Author

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
Contributor II
Contributor II

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

xuehaige2008
Contributor
Contributor

Hi, since I am new for Qlik, I feel confused about how to create field in my script. Can you give me a hint for this part? Thank you!

Irvin_Ceron
Partner
Partner

Y no hay una función que permita hacer eso mismo desde la expresión del gráfico?