Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to reference a value in line y of the script that was defined in line x of the script?

In the code below, I define [Days_Open] on the first line and want to reference it in the second line. My reload says the [Days_Open] field cannot be found.

Anyone know what's going on? How can I fix this?

Interval(Today()-[Entry Date],'d') as [Days_Open],

If([Days_Open]<=30,'0-30 Days','>30 Days') as [Days_Group]

1 Solution

Accepted Solutions
MarcoWedel

Table_1:

LOAD *,

           If([Days_Open]<=30,'0-30 Days','>30 Days') as [Days_Group];

LOAD ... //many fields

          Interval(Today()-[Entry Date],'d') as [Days_Open]

FROM ...

View solution in original post

8 Replies
johnca
Specialist
Specialist

Use a preceeding load statement.

Load

     If([Days_Open]<=30,'0-30 Days','>30 Days') as [Days_Group]; // Note the semi-colon

Load

     Interval(Today()-[Entry Date],'d') as [Days_Open],

     ...

HTH,

John

Not applicable
Author

John,

I just tried that as:

LOAD If([Days_Open]<=30,'0-30 Days','>30 Days') as [Days_Group];

Table_1:

LOAD ... //many fields

          Interval(Today()-[Entry Date],'d') as [Days_Open]

FROM ...

While I didn't get an error, Table_1 came up empty.

Did I organize the script incorrectly? Any other issues I'm not seeing?

MarcoWedel

Table_1:

LOAD *,

           If([Days_Open]<=30,'0-30 Days','>30 Days') as [Days_Group];

LOAD ... //many fields

          Interval(Today()-[Entry Date],'d') as [Days_Open]

FROM ...

johnca
Specialist
Specialist

Try rearranging the script a bit...


Table_1;

LOAD If([Days_Open]<=30,'0-30 Days','>30 Days') as [Days_Group];

LOAD ... //many fields

          Interval(Today()-[Entry Date],'d') as [Days_Open]

FROM ...



Not applicable
Author

Worked like a charm. Thank you Marco and John!

johnca
Specialist
Specialist

Oops, one more thing...(forgot the *)

Table_1;

LOAD

     *,

     If([Days_Open]<=30,'0-30 Days','>30 Days') as [Days_Group];

LOAD ... //many fields

          Interval(Today()-[Entry Date],'d') as [Days_Open]

FROM ...


johnca
Specialist
Specialist

thanks marco...again you step on my posts

MarcoWedel

just wanted to help ...

Naveed, please mark John's final answer as correct instead of mine.

thanks

regards

Marco