Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Previous() and Peek()

Difference between Previous() and Peek()

Please any one can give me Examples.......

5 Replies
nagarajupinnibo
Creator
Creator

can anyone explain with example of peek() and previous() functions???

Not applicable
Author

previous used to pull previous record

where as peek is used to pull both first and last record

see http://qlikshare.com/tag/peek

Example of Previous() & Peek()--

inputtable:

LOAD *,Previous(sales) as previous

INLINE [

    sales

    123

    153

    1456

    235

    845

    365

    896

    486

];

outputtable:

LOAD sales,

Peek(sales,3,'inputtable') as peek

     Resident inputtable;

peek
235

previous
123
153
235
365
845
896
1456

********************************************************************

Below()--

Returns values as they appear on the row below the current row within a column ,

On the last row of a column segment a NULL value will be returned, as there is no row below this one.

Above()--

values as they appear on the row above the current row within a column,

On the first row of a column segment a NULL value will be returned, as there is no row above this one

manideep78
Partner - Specialist
Partner - Specialist

Previous() - It always returns entire data except last record data.

Temp:

LOAD * INLINE [

    Emp_No, Emp_Name, Join_Date

    1, Manideep, 15-01-2013

    2, Pradeep, 16-02-2013

    3, Sandeep, 17-08-2012

    4, Navadeep, 19-06-2011

    5, Jayadeep, 16-12-2010

];

Previous:

LOAD Previous(Emp_Name) as Name        // It returns upto Navadeep

Resident Temp;

Nested_Previous:

LOAD Previous(Previous(Previous(Emp_Name))) as Name      // It returns only  Manideep and Pradeep

Resident Temp;

Peek(): It returns the content of specified filed name.

               Syntax:  peek(fieldname [ , row [ , tablename ] ] )

E_Name:

LOAD Peek('Emp_Name',0,'Temp') as E_Name    // It returns the first record. If we replace 0 with -1, it returns last record.

Resident Temp;


for more understanding see in help

Hope u got it now

Cheers

hic
Former Employee
Former Employee

The main difference is that Previous() fetches data from previous input record, whereas Peek() fetches data from previous output record. (Input to the Load statement and output of the Load statement.)

In addition, Peek() can be used to fetch data from other records than the previous and from other tables than the current, if the second and third parameters are used.

HIC

nagarajupinnibo
Creator
Creator

can anyone say about above() and below() functions with examples??