跳到主要内容

IntervalMatch

IntervalMatch 前缀用于创建表格以便将离散数值与一个或多个数值间隔进行匹配,并且任选匹配一个或多个额外关键值。

语法:  

IntervalMatch (matchfield)(loadstatement | selectstatement )

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

 

IntervalMatch 前缀必须置于加载时间间隔的 LOADSELECT 语句之前。在使用此语句和 IntervalMatch 前缀之前,包含离散数据点的字段(以下所示的 Time)必须已经加载到 QlikView。此前缀不会从数据库表格中读取此字段。此前缀将加载的时间间隔表格转换为包含其他列(离散数值数据点)的表格。另外其扩展了记录数,以使新表格对离散数据点、时间间隔和关键字段值的每个可能组合都有一条记录。

时间间隔可以重叠,离散值可以链接所有匹配的时间间隔。

扩展 IntervalMatch 前缀可在其创建表格时,使表格既能将离散数值和一个或多个数值时间间隔匹配,同时又能匹配一个或多个额外关键字段值。这是一个强大且灵活的功能,可用于链接交易与随时间改变的维度:渐变维度(Slowly Changing Dimension)

要避免未定义的时间间隔限值遭到忽略,可能必须让 NULL 可以映射到构成时间间隔下限或上限的其他字段。这可通过 NullAsValue 语句或显式测试来处理,显式测试可在任何离散数值数据点前后使用数值很好地替代 NULL

参数:  

IntervalMatch 参数
参数 说明
matchfield 一个字段,包含链接至时间间隔的离散数值。
keyfield 一个字段,包含转换中匹配的额外属性。
loadstatement or selectstatement 必会生成一个表格,其中第一个字段包含每个时间间隔的下半部限制,第二个字段包含每个时间间隔的上半部限制,如果使用关键字匹配,则第三个及此后的任何字段包含显示于 IntervalMatch 语句中的关键字段值。时间间隔总是封闭区间,即间隔的端点包括在时间间隔之中。非数值限值会导致时间间隔遭到忽略(未定义)。

示例 1:  

以下两个表格中,第一个表格定义了不同订单生产的开始时间和结束时间。第二个表格列出了众多离散事件。借助 IntervalMatch 前缀,可以逻辑连接两个表格,从而找出哪些订单受到干扰的影响,哪些订单依据哪次轮班处理。

EventLog:
LOAD * Inline [
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
];

OrderLog:
LOAD * INLINE [
Start, End, Order
01:00, 03:35, A
02:30, 07:58, B
03:04, 10:27, C
07:23, 11:43, D
];

//Link the field Time to the time intervals defined by the fields Start and End.
Inner Join IntervalMatch ( Time )
LOAD Start, End
Resident OrderLog;

结果

表格 OrderLog 现在包含额外一列:Time。记录的数量也可以扩展。

Example 1
Time Start End Order

00:00

- - -
01:18 01:00 03:35 A
02:23 01:00 03:35 A
04:15 02:30 07:58 B
04:15 03:04 10:27 C
08:00 03:04 10:27 C
08:00 07:23 11:43 D
11:43 07:23

11:43

D

示例 2: (使用 keyfield

与上述示例相同,添加 ProductionLine 作为关键字段。

EventLog:
LOAD * Inline [
Time, Event, Comment, ProductionLine
00:00, 0, Start of shift 1, P1
01:00, 0, Start of shift 1, P2
01:18, 1, Line stop, P1
02:23, 2, Line restart 50%, P1
04:15, 3, Line speed 100%, P1
08:00, 4, Start of shift 2, P1
09:00, 4, Start of shift 2, P2
11:43, 5, End of production, P1
11:43, 5, End of production, P2
];
 
OrderLog:
LOAD * INLINE [
Start, End, Order, ProductionLine
01:00, 03:35, A, P1
02:30, 07:58, B, P1
03:04, 10:27, C, P1
07:23, 11:43, D, P2
];
 
//Link the field Time to the time intervals defined by the fields Start and End and match the values
// to the key ProductionLine.
Inner Join
IntervalMatch ( Time, ProductionLine )
LOAD Start, End, ProductionLine
Resident OrderLog;

结果

现在可以按照以下方式创建表格框:

Example 2
ProductionLineTime EventCommentOrderStart End
P1

00:00

0Start of shift 1-- -
P201:000Start of shift 1---
P101:18 1Line stopA01:00 03:35
P102:23 2Line restart 50%A01:00 03:35
P104:15 3Line speed 100%B02:30 07:58
P104:15 3Line speed 100%C03:04 10:27
P108:00 4Start of shift 2C03:04 10:27
P209:00 4Start of shift 2D07:23 11:43
P111:43 5End of production-- -
P211:43 5End of productionD07:23 11:43

本页面有帮助吗?

如果您发现此页面或其内容有任何问题 – 打字错误、遗漏步骤或技术错误 – 请告诉我们如何改进!

加入分析现代化计划

Remove banner from view

使用分析现代化计划实现现代化,同时不损害您宝贵的 QlikView 应用程序。 单击此处 了解更多信息或联系: ampquestions@qlik.com