Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Load Script

Hi All

I need some help with load scripts:

I have a standard load script loading some data from excel sheet which is fine, i have a rather complicated if structure to calculate a value, lets call it 'Calculated Value A' which i save to the table structure, this all works great.

However in the same load script i want to access 'Calculated Value A' which I have just created and use it in further calculations, rather than just repeating the whole complicated if structure again is there a way to gain access to the value in the field that has just been created? 

Load

     line 1

     line 2

     if (  if ( if ( etc ))) as [Calculated Value A]

     if [Calculated Value A] = 'Yes' then do something

From

     etc etc

Thanks

JP

1 Solution

Accepted Solutions
Clever_Anjos
Employee
Employee

No, its correct.

When using pre load all happens bottom to up

Load // this happens affer load below

    *,

     if [Calculated Value A] = 'Yes' then do something;

Load // this happens first

     line 1

     line 2

     if (  if ( if ( etc ))) as [Calculated Value A]

From

     etc etc

View solution in original post

9 Replies
Clever_Anjos
Employee
Employee

Use a 'pre-load'

Load

    *,

     if [Calculated Value A] = 'Yes' then do something;

Load

     line 1

     line 2

     if (  if ( if ( etc ))) as [Calculated Value A]

From

     etc etc

Not applicable
Author

Hi JP

I think you can use the same calculation again but with an extra if statment:

Load

     Line1,

     Line2,

     IF( IF ( IF (ETC))) as [Calculated Value A],

     IF( IF( IF ( IF (ETC))) = 'Yes', something, somethingelse) as Somethingnew

From

Etc Etc

I hope this helps.

Michel

Not applicable
Author

Thanks Michel thats the solution I had but i thought it was rather messy and there had to be a better way.

Not applicable
Author

Hi Anjos

This looks sensible thanks, is the syntax as you have it with the 2 loads? if the script loads top to bottom should you not have it like this:

Load

     line 1

     line 2

     if (  if ( if ( etc ))) as [Calculated Value A]

Load

    *,

     if [Calculated Value A] = 'Yes' then do something;

From

     etc etc

Not applicable
Author

I've not used the pre-load option but you could also do it in 2 tables if you wanted to keep it neater.  So you use your first table as a temp table and then calculated off this.

Clever_Anjos
Employee
Employee

No, its correct.

When using pre load all happens bottom to up

Load // this happens affer load below

    *,

     if [Calculated Value A] = 'Yes' then do something;

Load // this happens first

     line 1

     line 2

     if (  if ( if ( etc ))) as [Calculated Value A]

From

     etc etc

Not applicable
Author

Perfect just tried it and it works a treat.

Thanks a mil for your help.

Cheers

JP

Clever_Anjos
Employee
Employee

JP,

Would you mind marking this discussion as answered?

Not applicable
Author

I was looking for that yesterday but I can't find it in the new layout ??

Sent from my iPhone