Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Previous() function in script

t1:
Load Week,
Material,
[Weekly Material Stock] as Stock1,
[Weekly Material Demand] as Demand1
Resident Temp_Table
where WOCHE = $(vFieldValue_1)
;


Let Stock = Previous('Stock1');

Trace $(Stock);

I wanted to see what values Stock takes in my loop

I see only stock1 in the trace but not the values it is taking. Anyidea how to change my trace so that I can see the values it is taking??

Regards

Sravan

8 Replies
Not applicable
Author

previous() references the field and values in the input table, which means that it can't be used outside of a load statement.

I would suggest that you use peek() instead.
To get the last record read:

LET Stock = peek('Stock1', -1, 't1');

Not applicable
Author

Hi Steffan,

with Peek also it does not work

see here in this thread

http://community.qlik.com/forums/t/44670.aspx

Thanks

Sravan

Not applicable
Author

It was quite a lengthy thread 🙂

However, I couldn't see that you had tested the exact same syntax that I suggested.
I saw the following row, but you are not defining the table as a string (with single quotation marks):
Let Stock = Peek('Stock1',-1,t1);

Try my suggestion in the example above and let me know if this works.

Kind regards

Not applicable
Author

HI Steffan,

Thanks and sorry for confusing. I edited the Script in the other thread and yes as in the example which I have attached in the other thread, I used the same syntax which you wrote here. The problem is that peek and concatenate somehow seems not to work. I described extensively my problem in other thread.

Thanks anyway for your help.

Regards

Sravan

Miguel_Angel_Baeyens

Hello Sravan,

I may have got you wrong, but if you want a list of possible values for field "Stock", once the whole table has been loaded, you can do as follows:

AllStockValues:LOAD CONCAT(DISTINCT Stock, ',') AS ValuesForStockRESIDENT t1;


If you mean you are within a loop and you want to know the last loaded value of "Stock", just do

LET vLastStockValue = Peek('Stock'); // No need for additional parameters


Hope that helps

Not applicable
Author

Hi Miguel,

I dont get you. I am attaching the Example and I explained my problem in the application. can you please help?

[View:http://community.qlik.com/cfs-file.ashx/__key/CommunityServer.Components.UserFiles/00.00.00.49.52/StockReporting.qvw]

Thanks

sravan

Not applicable
Author

Any Ideas profis Here:)

Not applicable
Author

Hi,

As the week changed I tried to change the present .qvw and upload. somehow it does not changeTongue Tied Here is the new one.

[View:http://community.qlik.com/cfs-file.ashx/__key/CommunityServer.Components.UserFiles/00.00.00.49.52/StockReportingLatest.qvw]

Regards

Sravan