Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
hic
Former Employee
Former Employee

A QlikView feature that is poorly known and brilliant in its simplicity is the Preceding Load.

 

If you don’t know what it is, then I strongly suggest that you read this blog post and find out. Because it will help you in your QlikView scripting.

 

So what is it?

 

It is a way for you to define successive transformations and filters so that you can load a table in one pass but still have several transformation steps. Basically it is a Load statement that loads from the Load/SELECT statement below.

 

Example: you have a database where your dates are stored as strings and you want to use the QlikView date functions to interpret the strings. But the QlikView date functions are not available in the SELECT statement. The solution is to put a Load statement in front of the SELECT statement: (Note the absence of “From” or “Resident”.)

 

Load Date#(OrderDate,’YYYYMMDD’) as OrderDate;
SQL SELECT OrderDate FROM … ;

 

What happens then is that the SELECT statement is evaluated first, and the result is piped into the Load statement that does the date interpretation. The fact that the SELECT statement is evaluated before the Load, is at first glance confusing, but it is not so strange. If you read a Preceding Load as

 

     Load From ( Select From ( DB_TABLE ) )

 

then it becomes clearer. Compare it with nested functions: How would you evaluate “Round( Exp( x ) )”. You would of course evaluate the Exp() function first and then the Round() function. That is, you evaluate it from right to left.

 

Input - Output.png

 

The reason is that the Exp() function is closest to the source data, and therefore should be evaluated first. It’s the same with the Preceding Load: The SELECT is closest to the source data and should therefore be evaluated first. In both cases, you can look at it as a transformation that has an input and an output and to do it correctly, you need to start with the part of the transformation closest to the input.

 

Any number of Loads can be “nested” this way. QlikView will start from the bottom and pipe record by record to the closest preceding Load, then to the next, etc. And it is almost always faster than running a second pass through the same table.

 

With preceding Load, you don’t need to have the same calculation in several places. For instance, instead of writing

 

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

 

where the same calculation is made for both Age and ReferenceDate, I would in real life define my ReferenceDate only once and then use 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 ;

 

The Preceding Load has no disadvantages. Use it. You’ll love it.

 

HIC

96 Comments
hic
Former Employee
Former Employee

You're right. A "Group By" is single threaded both in a standard Load and in a preceding Load.

HIC

0 Likes
498 Views
wdchristensen
Specialist
Specialist

Apparently another limitation of the preceding load is that it can’t use an “order by”.

Order By within Preceding Load

0 Likes
498 Views
stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

This makes sense.  A preceding load happens in the same pass of the data as the base load, and is therefore done in the same order.

If you need to order the data (the only reason I can see for this is to do an accumulation or other peek into previous rows) then you will need to use a temporary table and a RESIDENT load (ensuring you drop redundant tables after and avoid automatic concatenation).

Steve

498 Views
sajalgour2309
Contributor II
Contributor II

Hello All,

 

I have been using preceding load since I started working on Qlik and I love it but today I have found one strange thing (I might be wrong but this is why I need clarification )

When I do preceding load, load time is less but size of QVF increases a lot instead If I do resident size is less but time is more. I know all logic of why time is less I preceding but how does it impact on size of QVF i am not aware...

Any idea why this happens ?

Regards,

Sajal

0 Likes
498 Views
Tyler_Waterfall
Employee
Employee

@sajalgour2309 ---- when you say the size increases, do you mean the size of the app (qvf) on disk? Or do you mean the size in memory during reload?

And, are you sure you are ending up with the same data model in the app in both cases? Perhaps something else is happening or different fields are present/not present?

0 Likes
493 Views
sajalgour2309
Contributor II
Contributor II

Data model is exactly same. If you do a preceding load size of qvf (in disk) is more compare to if you do resident.

Ex. (Just a dummy example)

Tab1:

Load A+B as c,;

Load 

F*20 as A,

B

Resident Fact;

 

Or

Tab2:

Load F*20 as A, B  Resident Fact;

Tab1:

Load A + B as C Resident Tab2;

drop table Tab2;

 

In first approach time is less but size of QVF is more (on disk).

Thanks ,

Sajal

0 Likes
483 Views