Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
PLS EXPLAIN TO ME ABOUT THIS FUNCTION?
If(rowno()=1, Hired-Terminated, peek([Employee Count], -1)+(Hired-Terminated)) as [Employee Count],
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