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: 
vanderson009
Creator III
Creator III

Set Expression


Hi Community,

In my Database i have Stock data only for 1st Day Like

Day  Production  Sales  Stock

01    2                  3         11

02    4                  2

03    5                  3

04    2                  2

See i have Stock 11 for 1st Day and

Production is 2 that means Total Stock is 13 and sales is 3 so 13 - 3 = 10

Means My Closing Stock for 1st Day is 10. and 2nd day opening stock is 10 and so on......

I want to Displya like this.

Day  Production  Sales  Stock

01    2                  3         11

02    4                  2         10

03    5                  3         13

04    2                  2         13

Thanks and Regards,

Villyee

1 Reply
arbernardez_old
Partner - Contributor III
Partner - Contributor III

Hello Villiyee,

I think this could be what you are looking for:

Stock_temp:

LOAD * INLINE [

    Day, Production, Sales, Stock

    01, 2, 3, 11

    02, 4, 2,

    03, 5, 3,

    04, 2, 2,

];

Stock:

NoConcatenate

load

  Day,

  Production,

  Sales,

  if(len(trim(Stock))=0,peek(Stock)+peek(Production)-peek(Sales),Stock) as Stock

Resident Stock_temp order by Day;

drop Table Stock_temp;

exit Script;

Regards

Alberto Rodríguez.