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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
thanhphongle
Creator II
Creator II

Problem with using a variable in the script

Hello Community,

I have a problem with using a variable in a script.

See here:

Data:

LOAD *,

((Year(contract_end_date_cur)-year($(v_target_date)))*12+month(contract_end_date_cur)-month($(v_target_date))) as contract_term_remain;

Directory;

LOAD main_unique_id,

     customer,

     asset_model,

     contract_start_date,

     contract_end_date_cur

FROM

lease.one_import.xlsx

(ooxml, embedded labels, table is main);

let v_target_date = today();

QV returns me this error:

Error in expression:

')' expected

Data:

LOAD *,

((Year(contract_end_date_cur)-year(21.09.2017))*12+month(contract_end_date_cur)-month(21.09.2017)) as contract_term_remain;

I checked my expression. There's definetely not a ) missing.

Hope anyone can help me out here.

1 Solution

Accepted Solutions
marcus_sommer

I could imagine that the format of the variable is causing the error. Therefore either change the content of your variable to num(today()) or maybe floor(today()) or change the call of the variable to '$(v_target_date)'.

- Marcus

View solution in original post

4 Replies
prieper
Master II
Master II

Looks fine for me as well ....

does the script continue, i.e. why is there a ";" at the end of the statement?

Else would suggest to rewrite the expression (sometimes there might still be a bracket at the very right of the text),

or go through step-by-step.

marcus_sommer

I could imagine that the format of the variable is causing the error. Therefore either change the content of your variable to num(today()) or maybe floor(today()) or change the call of the variable to '$(v_target_date)'.

- Marcus

thanhphongle
Creator II
Creator II
Author

"does the script continue, i.e. why is there a ";" at the end of the statement?"

No, the script just ends there.

I tried to rewrite the expression several times, but the brackets are fine.

thanhphongle
Creator II
Creator II
Author

Thank you very much, it finally works !!

Your solutions

floor(today()) works,

'$(v_target_date)' works,

num(today()) does not work

THX!!