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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
jleefjcapital
Creator II
Creator II

What are the Peek() and Alt() functions used for?

I was recently introduced to the Alt() and Peek() functions.  I am not familiar with either and would like to know how these are used? 

5 Replies
sunny_talwar

From QV Help

Alt() function:

Capture.PNG

Peek() function:

Capture.PNG

HTH

Best,

Sunny

jagan
Partner - Champion III
Partner - Champion III

Hi,

Alt(Expression, DefaultValue )  - If the expression returns null then the second parameter value will be returned.

Example: Alt(Salesman, 'Others') - If salesman value is Null then it returns Others.

Peek() - Peek will return the Previous row value in a table of the given column.

Example:

Date, Sales

1/1/2015, 100

1/2/2015, 200

1/3/2015, 300

Result Peek():

Date, Sales, Peek(Sales)

1/1/2015, 100, Null  -- Returns Null since there is no previous row.

1/2/2015, 200, 100

1/3/2015, 300, 200

Hope this helps you.

Regards,

Jagan.

Anonymous
Not applicable

Hi

Check the link below

Alt function

Alexander_Thor
Employee
Employee

All replies has been great but here is some more context for you,

Alt() - Great to use in the load script to pad away missing values. You could of course achieve the same results with IF() statements or ApplyMap()

Peek() - In the load script I generally use Peek() when I need to loop data to create sequences. For example if transactions during a day should be sorted and given a sequence number. Certain systems would input changes to records as new rows and it would be a combination of the latest values and the "core" record that builds up the up-to-date record. You would find this behaviour in for example Oracle Peoplesoft.

Peak() is also useful in charts if you want to achieve a running total or sub-totals in tables. Another function whichyou could have used is Previous() which would look at the previous record just as Peek() would without any parameters.