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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Using EXISTS outside of a LOAD

Good afternoon all,

I have a FOR...LOOP where I want to check the existence of a field value in a conditional statement and thought 'exists' would do the job. However, I cannot seem to achieve it. Take this simple code below which shows the issue:

LOAD * INLINE [
F1, F2
A, 1
B, 2
C, 3
E, 4
G, 5
T, 6
];

LET vExists = if (exists(F1, 'B'), 1, 0);
IF vExists = 1 THEN
SET vVal = Y;
END IF

Is using 'exists' outside of a LOAD illegal? How can I achieve what I am after?

Help appreciated.

Regards,

Gordon

3 Replies
Not applicable
Author

I'm not sure if Exists can be used outside of a LOAD. You may be able to use Fieldindex() to do the same thing:

LET vExists = if (Fieldindex(F1, 'B') > 0, 1, 0);
IF vExists = 1 THEN
SET vVal = Y;
END IF


danielrozental
Master II
Master II

I don't believe you can use exists outside of a LOAD.

You can try lookup Let vAux = lookup('F1', 'F1', 'B');

If performance is a concert then you can do something like

LOAD * INLINE [

F1, F2

A, 1

B, 2

C, 3

E, 4

G, 5

T, 6

];

TAB1:

load

exists(F1, 'B') AS F3

AUTOGENERATE(1);

LET vExists = if (exists(PEEK('F3'), 'B'), 1, 0);

DROP TAB1;

IF vExists = 1 THEN

SET vVal = Y;

END IF



Not applicable
Author

Thanks chaps.

The fieldindex is the way to go for me but both solutions work.

Regards,

Gordon