Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Why does Load Resident work backwards ?


Hi All,

I am having to amend a dashboard which has a number of LOAD Resident statements in the script. However, I am confused by the syntax, or more accurately, the order in which the statements are executed within the script. For example....

TempTable:

LOAD
If(DurationInDays < 8,'One week','More than a week') as [DurationText],

*;

Load
StartDate - EndDate as DurationInDays,
*;

Load
*
Resident

EventTable;

I understand from this that TempTable is being loaded from EventTable, and that the DurationInDays field is being calculated from the difference between the Start date and End Date. The DurationText field is populated conditional on the value in DurationInDays. But how does that work ???

I've always believed QV executes its script from top to bottom and from left to right. This piece of script seems to read from the bottom up, else it wouldn't know what the value of DurationIndays was in the first line.

Can someone explain please ?

Thanks

MV

(PS No vague or ambiguous extracts from the QlikView Reference Manual please)

1 Solution

Accepted Solutions
johanlindell
Partner - Creator II
Partner - Creator II

Hi,

In this case, the LOAD statements are executed from the bottom up. This happens only if you put several LOAD statements without a "table" reference, like Resident, SQL SELECT... or Inline, that if you have a LOAD statement only defining fields and whereclauses etc

/* ececuted third reading from result from below*/

LOAD
If(DurationInDays < 8,'One week','More than a week') as [DurationText],

*;

/* ececuted second, reading from result from below*/

Load

StartDate - EndDate as DurationInDays,
*;

/* ececuted first, reading from Resident EventTable */
Load
*
Resident

EventTable;

/* ececuted fifth reading from result below*/

Load

*

Where [Col A] = 1;

/* ececuted forth reading from inline table*/


Load
*
Inline [

Col A, Col B

1, 2

2, 3   ];

View solution in original post

5 Replies
johanlindell
Partner - Creator II
Partner - Creator II

Hi,

In this case, the LOAD statements are executed from the bottom up. This happens only if you put several LOAD statements without a "table" reference, like Resident, SQL SELECT... or Inline, that if you have a LOAD statement only defining fields and whereclauses etc

/* ececuted third reading from result from below*/

LOAD
If(DurationInDays < 8,'One week','More than a week') as [DurationText],

*;

/* ececuted second, reading from result from below*/

Load

StartDate - EndDate as DurationInDays,
*;

/* ececuted first, reading from Resident EventTable */
Load
*
Resident

EventTable;

/* ececuted fifth reading from result below*/

Load

*

Where [Col A] = 1;

/* ececuted forth reading from inline table*/


Load
*
Inline [

Col A, Col B

1, 2

2, 3   ];

anbu1984
Master III
Master III

You are right script will execute from top to bottom and left to right.

But you have preceding Load. Preceding load executes from bottom up.

Table1:

Load *,Today();// Preceding Load

Load * Table1;

Table2:

Load * Table2;

In this example script will execute from Top to bottom. So first Table1 is executed and then Table2. In Table1 we have a preceding load, so innermost Load will execute first and followed by upper Load

If you have worked in Sql, preceding load is like this

Select * from ( Select * from Table1 )

Here Inner query is executed first and then outer query

Not applicable
Author

I understand now even though I find it rather illogical. But that's not a first from QlikView.

Many thanks for your clear explanation.

johanlindell
Partner - Creator II
Partner - Creator II

It is a very handy functionality though, where you can calculate new fields in "steps" based on fields created in the "logically previous" LOAD statement instead of having to read the table into a new table and drop the original one for each step.

/J