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

Calculate 2 Table to get a stock

Hello everyone 

I want to ask about a query in Qlik sense Can we calculate one by one ?  

For Example :

This Table Production

Production.png

 This Table A Sell

Sell.png

For my Result In column one I want Calculate Production - sell and a result get 80 and in Second Column i want to get 60 to get 60 i want calculate the stock in column one with - Second in column sell

Table excel 

Stock.png

For my Query in this 

Qliksense Data LOad.png

 And My result 

Qliksense.png

 Please Every One to Help me to resolve my problem Thank you 

2 Replies
rubenmarin

Hi, you can try renaming [PostingMonth of your production table to [CreateMonth], so after the join you end with a row that has ID, CreateMonth, Production and Sell.

The stock is Production-Sell, but it needs to accumulate from the first date, and probably you'll need a initial stock for each of your products, but for this adte, the accumulation can be done in the Calculate Table as:

Calculate:
LOAD
  ID,
  [CreateMonth]
  Production,
  Sell,
  RangeSum(Peek(Stock),Production,-Sell) as Stock
Resident Production
Order By CreateMonth;

DROP Table Production;
DROP Table Sell;

Note that I kept production and sell in this final tabla nd remove the previous table, so only the Calculate table i kept in the final data model. I also remove the ID =1234, I didn't know what are you trying to do in that syntax, if you want to apply a filter for a product you can use the Where clause (Resident production Where Id=1234...)

Viallijk
Contributor
Contributor
Author

Thank You for the response, i will try it