# class - script and chart function

The class function assigns the first parameter to a class interval. The result is a dual value with a&lt;=x&lt;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.

Syntax:

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

Arguments:

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:

Examples

| Example | Result |
| --- | --- |
| `class( var,10<br>					)` with `var = 23` | returns<br>'20&lt;=x&lt;30' |
| `class( var,5,'value'<br>					)` with `var = 23` | returns<br>'20&lt;= value &lt;25' |
| `class(<br>							var,10,'x',5<br>					)` with `var = 23` | returns<br>'15&lt;=x&lt;25' |

## Example - Load script using class

[](https://help.qlik.com/en-US/sense/Subsystems/Hub/Content/Sense_Hub/Scripting/ConditionalFunctions/class.htm)

#### Example: load script

Load script

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 original source table looks like the following.

Results

| 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.

Create a new tab in the data load editor, and then load the following data as an inline load. Create the table below in Qlik Sense to see the results.

```

LOAD *,
class(Age, 10, 'age') As Agegroup;

LOAD * INLINE
[ Age, Name
25, John
42, Karen
53, Yoshi];
```

Some of the examples in this topic use inline loads. For more information, see [Using inline loads to load data](https://help.qlik.com/en-US/sense/November2024/Subsystems/Hub/Content/Sense_Hub/Scripting/inline-loads-qs.htm).

Results

Results

| Name | Age | Agegroup |
| --- | --- | --- |
| John | 25 | 20 &lt;= age &lt; 30 |
| Karen | 42 | 40 &lt;= age &lt; 50 |
| Yoshi | 53 | 50 &lt;= age &lt; 60 |