Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
OK, guys, I have stuck and without your help I'll won't move forward :(.
What I need is in my load script to count the balance field .
I hope you will understand the calculation logic from the picture 🙂
Table:
LOAD * Inline [
Date, No, Location, Quantity
2021-01-01, A1235, M01, 3
2021-01-02, B1235, M02, 2
2021-02-03, A1235, M01, -1
2021-03-03, B1235, M02, 1
2021-03-04, C1235, M03, 2
2021-03-04, A1235, M01, -1
];
Hi @Rizzo , please add this script after your inline, and see if it works for you :
//the trick is order by Location field, to simplify the sum between rows.
Table2:
Load
*,
if(rowno()=1, Quantity,
if(previous(Location) = Location, Quantity + peek(Balance), Quantity)) as Balance;
Load
Date,
No,
Location,
Quantity
Resident Table
order by Location, Date;
drop table Table;
Hi @Rizzo , please add this script after your inline, and see if it works for you :
//the trick is order by Location field, to simplify the sum between rows.
Table2:
Load
*,
if(rowno()=1, Quantity,
if(previous(Location) = Location, Quantity + peek(Balance), Quantity)) as Balance;
Load
Date,
No,
Location,
Quantity
Resident Table
order by Location, Date;
drop table Table;
This is what I need.
Thank you!
And what would the script look like in set analysis if I wanted to get the same result?