Skip to main content

IntervalMatch

The IntervalMatch prefix is used to create a table matching discrete numeric values to one or more numeric intervals, and optionally matching the values of one or several additional keys.

Syntax:  

IntervalMatch (matchfield)(loadstatement | selectstatement )

IntervalMatch (matchfield,keyfield1 [ , keyfield2, ... keyfield5 ] ) (loadstatement | selectstatement )

 

The IntervalMatch prefix must be placed before a LOAD or a SELECT statement that loads the intervals. The field containing the discrete data points (Time in the example below) and additional keys must already have been loaded into Qlik Sense before the statement with the IntervalMatch prefix. The prefix does not by itself read this field from the database table. The prefix transforms the loaded table of intervals and keys to a table that contains an additional column: the discrete numeric data points. It also expands the number of records so that the new table has one record per possible combination of discrete data point, interval and value of the key field(s).

The intervals may be overlapping and the discrete values will be linked to all matching intervals.

In order to avoid undefined interval limits being disregarded, it may be necessary to allow NULL values to map to other fields that constitute the lower or upper limits to the interval. This can be handled by the NullAsValue statement or by an explicit test that replaces NULL values with a numeric value well before or after any of the discrete numeric data points.

Arguments:  

Argument Description
matchfield The field containing the discrete numeric values to be linked to intervals.
keyfield(s) Fields that contain the additional attributes that are to be matched in the transformation.
loadstatement or selectstatement Must result in a table, where the first field contains the lower limit of each interval, the second field contains the upper limit of each interval, and in the case of using key matching, the third and any subsequent fields contain the keyfield(s) present in the IntervalMatch statement. The intervals are always closed, i.e. the end points are included in the interval. Non-numeric limits render the interval to be disregarded (undefined).

Example 1:  

In the two tables below, the first one defines the start and end times for the production of different orders. The second one lists a number of discrete events. By means of the IntervalMatch prefix it is possible to logically connect the two tables in order to find out e.g. which orders were affected by disturbances and which orders were processed by which shifts.

OrderLog

 

 

Start

End

Order

01:00

03:35

A

02:30

07:58

B

03:04

10:27

C

07:23

11:43

D

EventLog

 

 

Time

Event

Comment

00:00

0

Start of shift 1

01:18

1

Line stop

02:23

2

Line restart 50%

04:15

3

Line speed 100%

08:00

4

Start of shift 2

11:43

5

End of production

First load the two tables as usual, then link the field Time to the time intervals defined by the fields Start and End:

SELECT * from OrderLog;

SELECT * from Eventlog;

IntervalMatch ( Time ) SELECT Start, End from OrderLog;

 

The following table box could now be created in Qlik Sense:

Tablebox

 

 

 

 

 

Time

Event

Comment

Order

Start

End

00:00

0 Start of shift 1 - - -
01:18 1 Line stop A 01:00 03:35
02:23 2 Line restart 50% A 01:00 03:35
04:15 3 Line speed 100% B 02:30 07:58
04:15 3 Line speed 100% C 03:04 10:27
08:00 4 Start of shift 2 C 03:04 10:27
08:00 4 Start of shift 2 D 07:23 11:43
11:43 5 End of production D 07:23

11:43

Example 2: (using keyfield)

Inner Join IntervalMatch (Date,Key) LOAD FirstDate, LastDate, Key resident Key;

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!