Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

If(rowno()=1, Hired-Terminated, peek([Employee Count], -1)+(Hired-Terminated)) as [Employee Count]

PLS EXPLAIN TO ME ABOUT THIS FUNCTION?

If(rowno()=1, Hired-Terminated,  peek([Employee Count], -1)+(Hired-Terminated)) as [Employee Count],

1 Reply
swuehl
MVP
MVP

It's a line from a LOAD statement (because you can only use peek() in a LOAD script, not in a chart).

It's basically creating a new field [Employee Count] from two other fields, Hired and Terminated,

calculating just Hired - Terminated for the first line of the output table, and the value from the previous output record for [Employee Count] plus Hired minus Terminated for all other lines.

For example, if your input table looks like

Hired, Terminated

30, 20

20, 10

20, 20

10, 0

Your Output table may look like

Hired, Terminated, Employee Count

30, 20, 10

20, 10, 20

20, 20, 20

10, 0, 30