Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

wajihakhan
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
shraddha_g
Honored Contributor III

Re: Set Expression in Load Script

MaxDate:

Load Max(YearMonthNumber) as YearMonthNumber

From XYZ;

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

Drop table MaxDate;

FinalTable:

Load Field1,

Field2,

YearMonthNumber,

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

From XYZ

Where YearMonthNumber = $(vYearNumber)

Group by Field1,Field2,YearMonthNumber;

vishalwaghole
Valued Contributor II

Re: Set Expression in Load Script

Small Correction in above logic,

MaxDate:

Load Max(YearMonthNumber)-1 as YearMonthNumber

From XYZ;

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

Drop table MaxDate;

FinalTable:

Load Field1,

Field2,

YearMonthNumber,

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

From XYZ

Where YearMonthNumber = $(vYearNumber)

Group by Field1,Field2,YearMonthNumber;

Regards,

Visahl Waghole

MVP
MVP

Re: Set Expression in Load Script

I suggest looking into The As-Of Table