Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anil_Babu_Samineni

Re: Peek function help

I have one small question, Peek(value) returns

returns the value of Value in the previous record read ( equivalent to previous(value) ).

Let's Assume

Name     Value

A               10

B               20

C               30

D               40

E               50

If we take, Peek(Value) as Value1, Then how result is visible?

Name     Value        Values

A               10      

B               20

C               30

D               40

E               50

Please add me Anil_Babu_Samineni to interact faster when reply back. Speak low think High.

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
7 Replies
ToniKautto
Employee
Employee

Anil, I branched this to a separate thread since it is not a question related directly to the thread where you posted it.

I do not completely understand you question. Can you please provide a sample QVW file where Peek() returns unexpected values?

It is incorrect that Peek() and Previous() are equivalent functions. Please review the definitions in help, Peek ‒ QlikView‌ and Previous ‒ QlikView‌, and consider the difference by for example applying the functions on your sample data.

LOAD

  *,

  Peek(Value) AS PeekValue,

  Previous(Value) AS PrevValue

Inline [Name, Value

A, 10

B, 20

C, 30

D, 40

E, 50]

Where Name <> 'C';

Anil_Babu_Samineni
Author

Thanks,

I want to know how values are coming for value1 while using peek from my table?

Please add me Anil_Babu_Samineni to interact faster when reply back. Speak low think High.

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
ToniKautto
Employee
Employee

I would suggest that you load the example script I added above. Then read the help pages, and reflect on what the example show you. Let me know if a result in that example does not make sense for you.

If you have an other example where the result do not turn up as you expected, please attach it so that we can explain why the result look the way they do.

Anil_Babu_Samineni
Author

Toni, First of all thanks.

Capture.PNG

For peek, It takes previous. But, I didn't understand why 30 will come?

Please add me Anil_Babu_Samineni to interact faster when reply back. Speak low think High.

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
trdandamudi
Master II
Master II

Previous() operates on the Input to the Load statement, whereas Peek() operates on the Output of the Load statement. That is the reason you are getting 30.

ToniKautto
Employee
Employee

There is a significant difference in the way Peek() and Previous() works.

Peek() is used to get a value from a in memory table, meaning data that has been processed and stored in the in-memory table. It can fetch the previous row stored, it can fetch data from any cell in any in-memory table.

Previous() is used to get a value from the record provided from the data source. 

In my example Name C is not loaded into memory. The record is still fetched from the data source. For Name D the previous record is Name C, and its value is 30. The conclusion of this is that you need to chose the correct function depending on what you intention is. Are you looking for a value that has been stored, or are you looking for a value from previous incoming record?

Anil_Babu_Samineni
Author

Nie, Cool and cheers explanation.

Please add me Anil_Babu_Samineni to interact faster when reply back. Speak low think High.

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)