Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
bartvanwetten
Creator
Creator

If statement with variable in load script

Dear,

I'm trying to check the existence of a field in table. I have a variable called vDS_JN  in which I put wether or not the field is present.

But why is it that my load statement is not honoring the if statement. (Error: fieldname does not exist 'ds')

The variable holds the value 'nee' so it should take 0 as value for the field ds

If the variable holds the value 'ja' it should use the existing field ds as ds. (this variant works without receiving the error).

Can someone help me out on this one?

Thank you very much in advance!

Bart

1 Solution

Accepted Solutions
bartvanwetten
Creator
Creator
Author

Reshma,

thx for the quick reply. If I unquote QlikView says that the 'field 'nee'' does not exist. If i use the variable without $ and quotes QlikView sees vDS_JN as a field so i get an error of course.

Spoken with QlikView support. They say that the use of the IF() in this particular way is out of league. I made my solution this way:

I create a separate table depending on the existence of the field DS. So my base structure of TRANSACT is always the same and the table. (I'm running in a for next loop with 1200 transact tables.

View solution in original post

7 Replies
reshmakala
Creator III
Creator III

you would not need quotes for the variables.... use $(vDS_JN) instead of '$(vDS_JN)'.

Hope it helps!

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Are you sure vDS_JN contains value 'nee'? Check the Document Log; In it, all text expansion is performed before the statements are printed. So you can see for yourself what the PRECEDING LOAD is trying to do during that particular run.

Best,

Peter

bartvanwetten
Creator
Creator
Author

Peter,

thx for the tip. Never knew that the log could show the debugged version of the preceding load!

The value was indeed 'nee' by the way.

Bart

alexandros17
Partner - Champion III
Partner - Champion III

When you use variable you have to omit ' otherways it is read as text so

'$(vDS_JN)' is exactly the string $(vDS_JN) not its value, write (all the varibles) without leading and trailing apex.

Let me know

bartvanwetten
Creator
Creator
Author

Reshma,

thx for the quick reply. If I unquote QlikView says that the 'field 'nee'' does not exist. If i use the variable without $ and quotes QlikView sees vDS_JN as a field so i get an error of course.

Spoken with QlikView support. They say that the use of the IF() in this particular way is out of league. I made my solution this way:

I create a separate table depending on the existence of the field DS. So my base structure of TRANSACT is always the same and the table. (I'm running in a for next loop with 1200 transact tables.

alexandros17
Partner - Champion III
Partner - Champion III

Use a text box , write in it $(vDS_JN) and analize the result.

bartvanwetten
Creator
Creator
Author

Dear Alessandro,

thx for the reply. Please look at the thread with Reshma.

Kind regards,

Bart