
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
From QV Help
Alt() function:
Peek() function:
HTH
Best,
Sunny

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

.png)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
