Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

jleefjcapital
Contributor

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
MVP
MVP

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

From QV Help

Alt() function:

Capture.PNG

Peek() function:

Capture.PNG

HTH

Best,

Sunny

MVP
MVP

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

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.

rgvavihs
Valued Contributor

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

Hi

Check the link below

Alt function

akl
Honored Contributor

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

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.