Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Let statement in load script Variable

Hello Im trying to create a max(Year) variable in load script instead of creating this in variable overview,

The variable gets created , but when i choose a different Year, it stays solid on the Max Year, where should i put the dollar expansion so the variable gets more dynamic ?

DATA:

LOAD ID,

     FirstName,

     LastName,

     Email,

     Country,

     Date,

     Year(Date) as Year,

     Month(Date) as Month

    

    

FROM

(ooxml, embedded labels, table is data);

Temp:

load max(Year) as MaxYear

resident  DATA;

let vMaxYear =  num(floor(Peek('MaxYear')));

drop table Temp;

1 Solution

Accepted Solutions
settu_periasamy
Master III
Master III

Because of the Temp Table Aggregation with Max(Year).

You will get only one Value in the Temp Table . i.e Maximum Year.

If you want to use the Maximum Year(vMaxYear) in the Script you can use

LET vMaxYear=num(floor(Peek('MaxYear')));

if you want the Max year as dynamic, you can create the variable Using SET statement. Like

SET vMaxYear='=Max(YearField)';

Script

DATA:

LOAD ID,

     FirstName,

     LastName,

     Email,

     Country,

     Date,

     Year(Date) as Year,

     Month(Date) as Month   

FROM

(ooxml, embedded labels, table is data);

SET vMaxYear='=Max(Year)';

if you want you can use the below script..

Temp:

load max(Year) as Year1

resident  DATA;

let vMaxYear1 =  num(floor(Peek('Year1')));

drop table Temp;

View solution in original post

2 Replies
settu_periasamy
Master III
Master III

Because of the Temp Table Aggregation with Max(Year).

You will get only one Value in the Temp Table . i.e Maximum Year.

If you want to use the Maximum Year(vMaxYear) in the Script you can use

LET vMaxYear=num(floor(Peek('MaxYear')));

if you want the Max year as dynamic, you can create the variable Using SET statement. Like

SET vMaxYear='=Max(YearField)';

Script

DATA:

LOAD ID,

     FirstName,

     LastName,

     Email,

     Country,

     Date,

     Year(Date) as Year,

     Month(Date) as Month   

FROM

(ooxml, embedded labels, table is data);

SET vMaxYear='=Max(Year)';

if you want you can use the below script..

Temp:

load max(Year) as Year1

resident  DATA;

let vMaxYear1 =  num(floor(Peek('Year1')));

drop table Temp;

Not applicable
Author

Hello, worked perfectly!