Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.


Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.


Inventory Closing Stock Amount Calculation

Hi all,

I have an issue in calculating closing stock amount.My requirement has been given in the attached application.Please follow the application and if you have any solution please share.I think it will calculated from the script end.


For any RecID,ITEM,Warehouse,Color, DimID combination if last row have QTY_StockIn value with >0  then that row will be considered otherwise any other previous row on behalf of the last row where  the QTY_StockIn value is >0 then that QTY_StockIn value and its corresponding  AMT_StockIn value should be considered to calculate the m_AMT_StockCL. And also apply the logic using RecordId because it is unique.Do not depend on the date as it cant be in a sorted manner but recordid corresponding to that date will always be unique.

Ex:-  On belhalf of the attached Application,


as per the example

Inventory Closing Qty:1200

Here on the last record,

QTY_StockIn    = -1350

but we have to find in which last entry QTY_StockIn is >0,

So on the previous record, QTY_StockIn is 1350 then that record will be considered, but for that case we find >0 value for QTY_StockIN on last previous record and it is not static for all cases we can find anywhere the last >0 value QTY_StockIn, If Last record value have QTY_StockIn >0 then that record should be considered for taking IN QTY and Amount.

So The m_AMT_StockCL=






*1200(Inventory Closing Qty) =95299.14

I think implementing that logic inside script will be a great thing. Please check and if find any solution then share here.

2 Replies
Contributor III

Re: Inventory Closing Stock Amount Calculation

hI I edited your set analysis for record id could you check if it is what you want?


Re: Inventory Closing Stock Amount Calculation

What you have done in UI level is it possible to be in script level. Because when I have no selection on ITEMID then I want to see all 2 product stock means there will be two line for 2 product. Is it possible do on script level.