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

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

if condition in load script

I have two Fields

FieldA has two values A and B

FieldB has Y and N

FieldC has numbers.

I am trying to fetch values from FieldC based on condition on FieldA and FieldB in the Load Script as below:

if([FieldA]='A' and [FieldB]='Y', [FieldC])

If FieldA has A and FieldB has Y as values, then the column FieldC should get all the values corresponding to the condition. But I get this error saying Invalid Expression. How to achieve this in Load Script level.

22 Replies
sunny_talwar

I don't see any issue with you if statement. Are you doing this within the LOAD statement right?

LOAD if([FieldA]='A' and [FieldB]='Y', [FieldC]) as RequiredField

swuehl
MVP
MVP

All three fields need to be part of your input table, they can't reside in separate tables. Is this true?

Then, could you post your complete LOAD statement? It's hard to tell why you get the error message without seeing the full context.

Anonymous
Not applicable
Author

UPDATE:

Field1, Field2 and Field3 are coming from the same table, Table1.

I am using this in the load of a new table:

Table2:

Load

Field1,

Field2,

Field3,

if(Field1='A', and FieldB='Y', then Field3) as [DefinedValue]

Resident Table1;

Anonymous
Not applicable
Author

Is it possible to take two fields from two different tables and use them in a third table using Resident load?

For example,

Field1 from Table1

Field2 from Table2

Table 3:

(Should have Field 1 and Field2).

Anonymous
Not applicable
Author

if(Field1='A' and FieldB='Y' or 'N', Field3) as [DefinedValue]

sunny_talwar

Try this:

If(Field1='A' and Match(FieldB, 'Y', 'N'), Field3) as [DefinedValue]

sunny_talwar

After you join them using JOIN functionality

swuehl
MVP
MVP

DRJ DJ wrote:

Is it possible to take two fields from two different tables and use them in a third table using Resident load?

For example,

Field1 from Table1

Field2 from Table2

Table 3:

(Should have Field 1 and Field2).

No, not without using inter record functions, like lookup(). Or maybe a MAPPING.

Anonymous
Not applicable
Author

This works in the Load script?, Sunny