Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
| rownum | Counter | Need | Qlik does this |
|---|---|---|---|
| 1 | 0 | 0 | 0 |
| 2 | 1 | 0 | 0 |
| 3 | 2 | 0 | 1 |
| 4 | 3 | 1 | 1 |
| 5 | 1 | 0 | 1 |
| 6 | 2 | 1 | 1 |
| 7 | 0 | 0 | 0 |
I want to flag the rows where peek(counter)<counter but the last column is what qlik does instead.
This load is reading a resident table. not sure if that makes a difference\
Thanks
This returns your desired results:
Data:
LOAD * INLINE [
rownum, Counter
1, 0
2, 1
3, 2
4, 3
5, 1
6, 2
7, 0
];
Test:
LOAD rownum, Counter, IF(PEEK(Counter) < Counter, 1, 0) as peek
RESIDENT Data
ORDER BY rownum DESC, Counter DESC;
DROP TABLE Data;
| rownum | Counter | peek |
|---|---|---|
| 1 | 0 | 0 |
| 2 | 1 | 0 |
| 3 | 2 | 0 |
| 4 | 3 | 1 |
| 5 | 1 | 0 |
| 6 | 2 | 1 |
| 7 | 0 | 0 |
I've also attached an example file.