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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Error in expression: AddYears takes 2 parameters

hello everybody. below the message i get while loading (generic field names for privacy):

Error in expression: AddYears takes 2 parameters

Concatenate

LOAD

AddYears (DATE, 1) as DATE,

NET_SALES_1,

GROSS_SALES_1,

PIECES_1

FROM

["EXCEL ORIGIN"]

Where

DATE <= AddYears(, -1)

in the latest AddYears, just above, on the script I put $(=max(DATE))

3 Replies
simospa
Partner - Specialist
Partner - Specialist

Hi,

please attach the snippet where you are assigning the value to the variable.

S.

rubenmarin

Hi, you can't use $(=max(DATE)) in script like in an expression.

One way to get that is:

- first load your dates using order by to get the max date in the first row:

Dates_tmp:

LOAD DATE as DATE_tmp

FROM.... order by DATE desc;

- assign that row value to a variable:

LET vMaxDate = Peek('DATE_tmp', 0, 'Dates_tmp');

-then you can use that variable in the where clause:

DATE <= AddYears('$(vMaxDate)' , -1)

Anonymous
Not applicable
Author

SET ThousandSep='.';

SET DecimalSep=',';

SET MoneyThousandSep='.';

SET MoneyDecimalSep=',';

SET MoneyFormat='€ #.##0,00;-€ #.##0,00';

SET TimeFormat='h.mm.ss';

SET DateFormat='DD/MM/YYYY';

SET TimestampFormat='DD/MM/YYYY h.mm.ss[.fff]';

SET MonthNames='gen;feb;mar;apr;mag;giu;lug;ago;set;ott;nov;dic';

SET DayNames='lun;mar;mer;gio;ven;sab;dom';

TransactionTable:

LOAD

ID,

SHOP,

DATE,

NET_SALES,

GROSS_SALES,

PIECES

FROM

[EXCEL];

Concatenate

LOAD

AddYears (DATE, 1) as DATE,

NET_SALES_1,

GROSS_SALES_1,

PIECES_1

FROM

[EXCEL]

Where

DATE <= AddYears($(=max(DATE)), -1);

DataTable:

load distinct

DATE,

month(DATE) as MONTH,

year(DATE) as YEAR

resident TransactionTable;

ABOVE MY COMPLETE LOAD SCRIPT, I JUST WANTED TO RECREATE THIS CENARY