- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to get the stock value from previous row
Hi Everyone,
Please help me to find the formula script based on previous row.
Now I want to calculate the stock for all the months and the formula is :
((currentMonthProduction * Previous month stock) + (current month Sell )) / (Previous month production - current month production)
Let me give an example of how the data is
Please help me to write this script?
Thank you
- Subscribe by Topic:
-
Chart
-
Client Managed
-
Data Load Editor
-
dimension
-
expression
-
General Question
-
Script
-
Set Analysis
-
Variables
-
Visualization
- « Previous Replies
-
- 1
- 2
- Next Replies »
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
Based on my understanding, for 1st row, its Production - Sell to get the Stocks. If so, try like below
Load *,
If(Rowno() =1, Production - Sell, ((Production * Peek('StockField')) + (Sell))
/
(Peek('Production') - Production)) as StockField
resident ursource
order by Month;
Please close the thread by marking correct answer & give likes if you like the post.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi
have you tried to use the function 'peek' -
Peek - script function ‒ Qlik Sense on Windows
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yes, but I don't know the combination formula.
Can you write example formula for this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Fears of a potential economic slowdown are clouding the outlook for value stocks, which have outperformed broader indexes this year in the ...Hyperfund Login
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
try this -
((currentMonthProduction * Peek('StockField',0,'TableName')) + (current month Sell ))
/
(Peek('productionField',0,'TableName') - current month production)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, try with the previous() function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jmartineze,
Can you write the sample combination formula with previous() ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
load
....
((currentMonthProduction * Previous( month stock)) + (current month Sell )) / (Previous( month production) - current month production) as NameField
from Table;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
Based on my understanding, for 1st row, its Production - Sell to get the Stocks. If so, try like below
Load *,
If(Rowno() =1, Production - Sell, ((Production * Peek('StockField')) + (Sell))
/
(Peek('Production') - Production)) as StockField
resident ursource
order by Month;
Please close the thread by marking correct answer & give likes if you like the post.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi MendyS,
Thanks for your reply. But its not working for my expectation.
- « Previous Replies
-
- 1
- 2
- Next Replies »