
Expression first record calculation differs from subsequent calculations  how to?
Brandon Apperson Mar 2, 2012 1:39 PM (in response to M Paeper)The way I was able to implement this in the script was by using the peek function. When reloading the script the peek function will look at the previous field's value in the data.
Since I don't have the original excel spreadsheet I created an inline table similar to the data set above.
test:
LOAD * INLINE [
Order, New, Mach
1, 297622, 324082
2, 278174, 320720
3, 405872, 311627
4, 288244, 313817
]
;
test2:
LOAD *,
New  Mach as Calc
Resident test;
Drop table test;
test3:
LOAD *,
IF (rowno() = 1, Calc, IF (rowno() >= 2, peek([New vs Mach]) + Calc)) as [New vs Mach]
Resident test2;
Drop table test2;
So the basic idea is create a field called Calc that does the basic NewMach equation.
Then create the New vs Mach field, for the first row just use the Calc field like you mentioned earlier, but if its the second row or above you need to use peek([New vs Mach]) + Calc.
This produces the same results as what you got in excel (for me at least).
Hope this helps...
Brandon

Expression first record calculation differs from subsequent calculations  how to?
M Paeper Mar 6, 2012 4:56 AM (in response to Brandon Apperson)Hi Brandon,
Fantastic! Your solution works 100% for me. Thanks very much for a brilliant answer.
