Skip to main content

Preceding LOAD


Preceding LOAD

The preceding LOAD feature allows you to load a table in one pass, but still define several successive transformations. Basically, it is a LOAD statement that loads from the LOAD or SELECT statement below, without specifying a source qualifier such as From or Resident that you would normally do. You can stack any number of LOAD statements this way. The statement at the bottom will be evaluated first, then the statement above, and so on until the top statement has been evaluated.

You can achieve the same result using Resident, but in most cases a preceding LOAD will be faster.

Another advantage of preceding load is that you can keep a calculation in one place, and reuse it in LOAD statements placed above.

Note: The following prefixes cannot be used in conjunction with preceding LOAD:Join, Crosstable and Intervalmatch.

Example 1: Transforming data loaded by a SELECT statement

If you load data from a database using a SELECT statement, you cannot use QlikView functions to interpret data in the SELECT statement. The solution is to add a LOAD statement, where you perform data transformation, above the SELECT statement.

In this example we interpret a date stored as a string using the QlikView function Date# in a LOAD statement, using the previous SELECT statement as source.

LOAD Date#(OrderDate,'YYYYMMDD') as OrderDate;

Example 2: Simplifying your script by reusing calculations

In this example we use a calculation more than once in the script:

LOAD ..., Age( FromDate + IterNo() – 1, BirthDate ) as Age, Date( FromDate + IterNo() – 1 ) as ReferenceDate Resident Policies While IterNo() <= ToDate - FromDate + 1 ;

By introducing the calculation in a first pass, we can reuse it in the Age function in a preceding LOAD:

LOAD ..., ReferenceDate, Age( ReferenceDate, BirthDate ) as Age; LOAD *, Date( FromDate + IterNo() – 1 ) as ReferenceDate Resident Policies While IterNo() <= ToDate - FromDate + 1 ;