Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
please, look at my script:
load
id,
text,
balance,
Previous(debt) - balance as debt
;
load * inline [
id, text, balance, debt
0,,,400
1, aaa, 250, 0
2, bbb, 200, 0
3, ccc, 100, 0
];
I expected this:
0, , , -
1, aaa, 250, 150
2, bbb, 200, -50
3, ccc, 100, -150
but, result is:
0, , , -
1, aaa, 250, 150
2, bbb, 200, -200
3, ccc, 100, -100
What's wrong in my script?
Thanks in advance!
Previous(debt) returns
-
400
0
0
which when evaluated as Previous(debt)-balance gives
-
150
-200
-100
Regards
Pratyush
Debt is 0 for all except the first row, I think you want this
Load
id,
text,
balance,
balance - Previous(balance) as debt
;
load * inline [
id, text, balance, debt
0,,400,
1, aaa, 250, 0
2, bbb, 200, 0
3, ccc, 100, 0
];
Try this..
Load
id,
text,
balance,
Previous(balance) as Prev,
if(RowNo()>2, Peek(dept)-balance,Previous(balance)-balance) as dept
;