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 statement with a load value

Hello,

I have a trouble with two if statement.

The second if use a value that is create in the first if statement.

LOAD

//First if

if(a<>0, a+1, a+2) as [Value 1],

//Second if

if(b=0, b+2, [Value 1]) as [Value 2]

With this, I obtain an error "Could not find field - <Value 1>.

Can you help me with this ?

Thanks

3 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Use a preceeding load

LOAD

     *,

     if(b=0, b+2, [Value 1]) as [Value 2]

;

LOAD if(a<>0, a+1, a+2) as [Value 1],

      other fields...

FROM ...

;

-Rob

Not applicable
Author

You can't refer to "newly defined fields" as part of the initial load. You would need to do a JOIN LOAD from the same table in order to add your second field by referring to Value 1, or simply restate the same IF condition from your definition of Value 1

if (b=0, b+2, If(a<>0, a+1, a+2)) as [Value 2]

Not applicable
Author

Thanks to you two