Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

garbage after expression: “)” with a variable

Hi,

I use the following variable to calculate the differences between 2 dates.


//Calculate differences between 2 dates

SET MonthDiff = Num(((year($2) * 12) + month($2)) - (((year($1) * 12) + month($1))) + 1);

LET vDateExampleEuropeanFormat = '18/05/2017';

LET vDateStartConsultant = 'date(date#(DateStart,' & chr(39) & 'YYYYMMDD' & chr(39) & '),' & chr(39) &      'DD/MM/YYYY' & chr(39) & ')';

LOAD * INLINE [
Consultant, DateStart
John, 20150126
Maria, 20151204
Paul, 20170912
]
;

It is working fine when I use MontDiff function in a table with vDateExampleEuropeanFormat variable. However when I use it with vDateStartConsultant I receive the error:  garbage after expression: “)”

I am attaching an example.

Could you please help me with this issue?

1 Solution

Accepted Solutions
el_aprendiz111
Specialist
Specialist

Hi,

not '

=$(MonthDiff(vDateStartConsultant, Today()))

View solution in original post

3 Replies
el_aprendiz111
Specialist
Specialist

Hi,

not '

=$(MonthDiff(vDateStartConsultant, Today()))

Anonymous
Not applicable
Author

Hi,

thank you so much for your answer!

I am very confused. Could you please clarify why we have to use vDateStartConsultant in this case -Without “$” and quotes-? In the other example I put ‘$(vDateExampleEuropeanFormat)’-(With “$” and quotes)  and it works well

=$(MonthDiff('$(vDateExampleEuropeanFormat)', Today()))        //it works well

=
$(MonthDiff('$(vDateStartConsultant)', Today()))           //it DOESN’T work well

=
$(MonthDiff(vDateStartConsultant, Today()))         //it works well

Thanks in advance

marcus_sommer

Put both variables into a textbox and you will see that the first returned:

18/05/2017

and the second:

'18/05/2017'

and if the second variable is then called with single-quotes per '$(variable)' you will double the quotes and receive a (still) error in the result of NULL. This meant creating and calling a variable depends on eachother.

- Marcus