Skip to main content

class - script and chart function

The class function assigns the first parameter to a class interval. The result is a dual value with a<=x<b as the textual value, where a and b are the upper and lower limits of the bin, and the lower bound as numeric value.


class(expression, interval [ , label [ , offset ]])


Class arguments
Argument Description
interval A number that specifies the bin width.
label An arbitrary string that can replace the 'x' in the result text.
offset A number that can be used as offset from the default starting point of the classification. The default starting point is normally 0.

Examples and results:  

Examples 1-3 and results
Example Result
class( 23,10 ) returns '20<=x<30'
class( 23,5,'value' ) returns '20<= value <25'
class( 23,10,'x',5 ) returns '15<=x<25'

In this example, we load a table containing name and age of people. We want to add a field that classifies each person according to an age group with a ten year interval. The source table looks like this:

Source table
Name Age
John 25
Karen 42
Yoshi 53

To add the age group classification field, you can add a preceding load statement using the class function. In this example, we load the source table using inline data.

LOAD *, class(Age, 10, 'age') As Agegroup; LOAD * INLINE [ Age, Name 25, John 42, Karen 53, Yoshi];


The resulting data that is loaded looks like this:

Results table
Name Age Agegroup
John 25 20 <= age < 30
Karen 42 40 <= age < 50
Yoshi 53 50 <= age < 60

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!

Join the Analytics Modernization Program

Remove banner from view

Modernize without compromising your valuable QlikView apps with the Analytics Modernization Program. Click here for more information or reach out: