# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

New Contributor II

## Set Expression in Load Script

How can i achieve this below expression in load script?

Sum({\$<YearMonthNumber = {"\$(=Date(Date#(Max(YearMonthNumber),'YYYYMM')-1,'YYYYMM'))"}, Month = , MonthYearName = , Year = >} [Opening Stock])

Regards

3 Replies
Honored Contributor III

## Re: Set Expression in Load Script

MaxDate:

From XYZ;

Let vYearNumber = peek('YearMonthNumber',0,'MaxDate');

Drop table MaxDate;

FinalTable:

Field2,

YearMonthNumber,

Sum("Opening Stock") as "Opening Stock"

From XYZ

Where YearMonthNumber = \$(vYearNumber)

Group by Field1,Field2,YearMonthNumber;

Valued Contributor II

## Re: Set Expression in Load Script

Small Correction in above logic,

MaxDate:

From XYZ;

Let vYearNumber = peek('YearMonthNumber',0,'MaxDate');

Drop table MaxDate;

FinalTable:

Field2,

YearMonthNumber,

Sum("Opening Stock") as "Opening Stock"

From XYZ

Where YearMonthNumber = \$(vYearNumber)

Group by Field1,Field2,YearMonthNumber;

Regards,

Visahl Waghole

MVP

## Re: Set Expression in Load Script

I suggest looking into The As-Of Table