📜  QlikView-IntervalMatch(1)

📅  最后修改于: 2023-12-03 15:34:34.078000             🧑  作者: Mango

QlikView-IntervalMatch

QlikView-IntervalMatch is a powerful feature in QlikView that allows you to associate a set of values with a range of intervals.

How it works

IntervalMatch uses two tables: a target table and a source table. The target table contains a field that is used to associate the target row with a source row. The source table contains two fields that define the range of intervals. The IntervalMatch function selects the target rows and finds the first source row where the value falls within the range of intervals. The resulting table contains all the target fields plus the matching source fields.

Use cases

IntervalMatch can be useful when you need to associate rows in a target table with a range of values in a source table. For example, you might use IntervalMatch to associate sales data with a target table of customers based on their zip code. Another example might be to associate temperature data with a target table of cities based on their latitude and longitude.

Syntax

The IntervalMatch function is used in the script editor in QlikView. The syntax is as follows:

IntervalMatch(TargetField, StartValue, EndValue [, SourceTable])
  • TargetField: The name of the field in the target table that will be used for the association.
  • StartValue: The name of the field in the source table containing the start value for the range of intervals.
  • EndValue: The name of the field in the source table containing the end value for the range of intervals.
  • SourceTable (optional): The name of the source table. If omitted, the function will use the current script table as the source table.
Example
TargetTable:
LOAD * INLINE [
    CustomerID, ZipCode
    1, 90210
    2, 10011
    3, 60601
];

SourceTable:
LOAD * INLINE [
    ZipCodeStart, ZipCodeEnd, Region
    90000, 90999, West
    10000, 19999, East
    60000, 69999, Midwest
];

IntervalMatch(ZipCode, ZipCodeStart, ZipCodeEnd, SourceTable);

JOIN (TargetTable)
LOAD * INLINE [
    Region, Sales
    West, 1000
    East, 2000
    Midwest, 1500
];

In this example, we are associating a set of zip codes with a set of regions using IntervalMatch. The resulting table contains the TargetTable fields (CustomerID and ZipCode) plus the matching SourceTable field (Region). We then join this table with a table of sales data by region to get the total sales for each customer's region.