Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Create historic Stock Level Count

Hi There QlikViewers

I am struggling to develop the expression I need to show my historic stock levels.  The fields I am working with are;

  • Purchased Date
  • Sales Date

I want to be able to display my historic stock levels by referencing the Purchased Date to the Sales Date.  So, in this example....

ItemQuantityPurchased DateSales Date
Apples10001/01/201503/01/2015
Oranges5003/01/2015
Pears2502/01/2015
Apples20002/01/2015

...the stock levels by item quantity by date would be;

DateStock Level
01/01/2015100
02/01/2015325
03/01/2015275
04/01/2015275

I have been trying to work this out and have got completely stuck!  Any help appreciated!

8 Replies
robert_mika
Master III
Master III

Why do we have this line?

04/01/2015275
Gysbert_Wassenaar

See attached example.


talk is cheap, supply exceeds demand
Not applicable
Author

Hi,

The line 04/01/2015 was just to show that the stock level would still be at 275 on that day because no transactions had taken place.

JW

Not applicable
Author

Hi There

Many thanks for your reply. 

This seems to work in your example qvw but I am not sure what the LEN(TRIM statement in the load script is doing with the date and what the RANGESUM(ABOVE expression is doing to the stock calculation. 

I've looked in the help menu but I have not understood. 

Please could you explain?

Thanks

JW

robert_mika
Master III
Master III

So if transaction is not taken place on 4,5,6... you still need to see this a a part of solution?

Not applicable
Author

Hi Robert

Yes, if no transactions have occured since 03/01/2015 I would want to see an entry for each day up to today. 

So today would show as 30/07/2015, 275.

JW

Gysbert_Wassenaar

The len(trim(..)) is to check if there is a value or not. The rangesum function is used in combination with the above() function to accumulate the stock amounts of each row.


talk is cheap, supply exceeds demand
qlikviewwizard
Master II
Master II

Hi Justine Willcox

Gysbert Wassenaar's solution is meets your requirement.

Can you attach the file with sample data you are using. So that it will help the folks to give faster solution.