Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
LeonardoB25
Contributor II
Contributor II

Error in arithmetic operation in script load editor

Hello, this is a snippet of my script load editor:

LeonardoB25_0-1695042758699.png

I have the error "unexpected token" at line 68, the [Data Documento] on the right is the problem. Compiler expects an operator, a ':' or a ','. I really don't understand why it's wrong, since syntax seems correct from what i saw online.

 

Here the error log:

LeonardoB25_1-1695042875529.png

 

 

Labels (1)
1 Solution

Accepted Solutions
marcus_sommer

Your age-variable assignment is wrong and results in NULL which removed the variable. Reason is your attempt to access maxdata. In general no values could be accessed on the outside of load-statements unless using functions like peek() or fieldvalue() and so your variable-creation may look like:

let var = fieldvalue('fieldname', 1);

View solution in original post

11 Replies
fachto76
Contributor II
Contributor II

Hi , you can't define [Data Documento] twice.

[Data Documento], $(AgeofMostRecentDate) AS [Data Documento2]  should work

marcus_sommer

Your age-variable assignment is wrong and results in NULL which removed the variable. Reason is your attempt to access maxdata. In general no values could be accessed on the outside of load-statements unless using functions like peek() or fieldvalue() and so your variable-creation may look like:

let var = fieldvalue('fieldname', 1);

LeonardoB25
Contributor II
Contributor II
Author

hello. Thanks for your reply. Unfortuntely, I already tried some different names on the right of the AS, such as [Nuova Data Documento] (which means new document date), but I got the same problem.

 

LeonardoB25
Contributor II
Contributor II
Author

Hello, thanks for your reply. From what I can see from documentation, it appears that fieldvalue with 1 accesses the first element in the loading order of that field. I don't understand how can this solve a problem. Does it fetch the biggest (most recent) date in that field even from outside the load statement?

marcus_sommer

The field-value access per peek() and fieldvalue() is only on a defined index - but the table-records and/or field-values could be loaded in a certain order which makes a sensible access possible - especially if the first and/or last values are the wanted ones.

In regard to your case I referred to maxdata which you creates the step before and this table has just a single record and therefore the access per:

let var = fieldvalue('fieldname', 1);

or alternatively

let var = peek('fieldname', 0, 'tablename');

will work.

LeonardoB25
Contributor II
Contributor II
Author

LeonardoB25_0-1695056282111.png


Thanks for your reply. Unfortunately, the error persists the same even after i changed the variable declaration as you said. ("unexpected token: [Nuova Data Documento]")

marcus_sommer

My examples were with var/fieldname/tablename just generic - you need to apply the existing ones.

LeonardoB25
Contributor II
Contributor II
Author

sorry I'm stupid as hell. Will try now.

LeonardoB25
Contributor II
Contributor II
Author

LeonardoB25_0-1695121341809.png

unfortunately, the exactly same error persists even after your suggestions. I really don't know what could be the problem at this point

thank you anyway