Qlik Community

Qlik Education Documents

Documents related to Qlik Education.

Segmentation of values with irregular ranges

vbarbera
New Contributor

Segmentation of values with irregular ranges

I was thinking about how to segment the employees of the company according to their age and I found the "Class" function. It is very interesting and very comfortable when the intervals are regular, 5 in 5 or 10 in 10, for example. But when the intervals are different from each other, it does not work well for us.

I think a good solution, which seems to work correctly and is very flexible, is to use the "IntervalMatch" function. It behaves similarly to the Excel Vlookup function.

The magic is in this function that manages to make a relation based on the definition of the intervals.

//Load Employees

employees:

Load * Inline [

Name, Age

Nieves, 21

Enrique, 48

Alberto, 22

Sergio, 23

Pedro, 23

Fran, 18

Víctor, 47

Cervanes, 64

];

// Load intervals or ranges

ageSegmentation:

Load * Inline [

Start, End, Group

18, 20, Young

21, 25, AlmostYoung

26,49, Adult

50,150, Senior

];

// The magic is in this function that manages to make a relation based on the definition of the intervals.

Inner Join IntervalMatch (Age)

Load Start, End

Resident ageSegmentation

I hope this is useful for you

Version history
Revision #:
1 of 1
Last update:
‎03-16-2017 09:27 AM
Updated by: