Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

If field is not found, load as blank, else load as it is

I have a txt file which contains fields A,B ,C. However, some of the txt files only contains fields B and C. I am using a wild card * load to load all txt files whether they have field A or not. If they have field A, I want them to load, else load as BLANK.

How do I write something like

IF (A, A, ' ')  AS COLUMN_A

Thank you

13 Replies
Anonymous
Not applicable
Author

Set NullAsValue Field1, Field2;

Have a look at the help.

You have to use a comma separated field list.

(I never tried it)

Peter_Cammaert
Partner - Champion III
Partner - Champion III

From the same discussion: Re: how to identify if a field is present in the load statement?

Loading with wildcards may present problems. For example, they don't take PRECEDING LOADs. If your file names follow a particular "file mask", you would better create a FOR EACH loop and load'n'process these files individually. All with a generic LOAD statement...

Anonymous
Not applicable
Author

You also could

Set NullAsValue*;

then do your concatenations and then reset it

Set NullAsNull *;

----------------------------

Could also be that you have to do a dummy

LOAD * on the whole table for replacing the null()s

at the end of the process...

parul_mehta
Partner - Creator
Partner - Creator

You can try the below code

Set ErrorMode = 0;

TEMP:
LOAD * INLINE [
T1, T2
A, 1
B, 2
C, 3
]
;

NoConcatenate
 
LOAD T1,T2,T3 Resident TEMP;
 
if $(ScriptError)=11 then
 
LOAD T1,T2 Resident TEMP;
ENDIF;
 
Set ErrorMode = 1;

Attached document for exception handling details.