Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

calculate fieldvalue based on previous record, only field value first record is known

Simplified example:

I'm trying to calculate a fieldvalue in every row of a table.The calculation of the value is based on the previous record where only the first record is known. The formula looks like this: 6 * previous(fieldvalue).

Only the value of the first record is known. For example the Calculatedfield value of record 4 is based on the previous calculatedfield value of record 3 which is unknown.

RowIDCalculatedfield
12
2
3
4
5
6

I tried some do while loops but I can't get it to work. Any suggestions are very welcome!

1 Solution

Accepted Solutions
ToniKautto
Employee
Employee

You shoul be able to solve that operation by using Peek() during load.

T1:
LOAD * Inline [
F1, F2
1, 4
2, 0
3, 0
];

T2:
LOAD
F1 as F3,
if(RowNo()=1, F2, Peek(F4) * 6) as F4
RESIDENT T1;



View solution in original post

2 Replies
ToniKautto
Employee
Employee

You shoul be able to solve that operation by using Peek() during load.

T1:
LOAD * Inline [
F1, F2
1, 4
2, 0
3, 0
];

T2:
LOAD
F1 as F3,
if(RowNo()=1, F2, Peek(F4) * 6) as F4
RESIDENT T1;



Not applicable
Author

Thanks Toni, exactly what I was looking for. Good to know that QV peek function looks at the previous modified record and not at the 'original' table record.