Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

variable LET script error

Hello! Can someone explain me, please, why does

LET vMonthStart=MonthStart(max(Date));

//Date is a field of previously loaded table

cause a script line error?

Regards,

Alexa

18 Replies
Not applicable
Author

With code like this

TempTable1:

LOAD

Max( Date) as MaxDate

Resident FACT;

Let vMaxDateNum = Num( Peek( 'MaxDate', 0, 'TempTable1'));

Let vMaxDate = Date( $(vMaxDateNum));

LET vMonthStart=MonthStart(FieldValue('MaxDate', 1));

LET vPeriod=$(vMaxDate)-$(vMonthStart);

it almost works=)))

I get an error "script line error LET vPeriod=08.12.2014-01.12.2014"

what does Qlik need to be this right? date#, num() doesnt work as well...

Not applicable
Author

Thanks, Yoann.

With code like this

TempTable1:

LOAD

Max( Date) as MaxDate

Resident FACT;

Let vMaxDateNum = Num( Peek( 'MaxDate', 0, 'TempTable1'));

Let vMaxDate = Date( $(vMaxDateNum));

LET vMonthStart=MonthStart(FieldValue('MaxDate', 1));

LET vPeriod=$(vMaxDate)-$(vMonthStart);

it almost works=)))

I get an error "script line error LET vPeriod=08.12.2014-01.12.2014"

what does Qlik need to be this right? date#, num() doesnt work as well...

yduval75
Partner - Creator III
Partner - Creator III

LET vPeriod=$(vMaxDate)*1-$(vMonthStart)*1;

Not applicable
Author

doesnt help=( same error

fernando_tonial
Employee
Employee

Hi, Try this code.

LET vPeriod=Num('$(vMaxDate)')-Num('$(vMonthStart)');

Best Regards.

Tonial.

Don't Worry, be Qlik.
Not applicable
Author

It doesnt work=(

Qlik counts everithing exept

period

fernando_tonial
Employee
Employee

Hi, try this.

LET vPeriod=$(vMaxDateNum)-$(vMonthStartNum);

Best Regards.

Tonial.

Don't Worry, be Qlik.
Not applicable
Author

hmmm... now it works=))))

Thank you!=)

But I really dont understand its logic...

fernando_tonial
Employee
Employee

Maybe this error occurring because the QlikView interpreting this variable (vMaxDate and vMonthStart) as text instead of number or date.

Don't Worry, be Qlik.