[CLOSED]Calculation Between Next Row and Current Row
Hello,
I am looking for a keyword that will let me grab the value of the next row to use in a calculation in the current row. There is already a keyword for the last row but I can't seem to find it after looking through documentation. We would like to avoid using hold files at all.
example:
TABLE FILE CAR SUM DEALER_COST COMPUTE TEST/D12 = DEALER_COST + LAST DEALEAR_COST; AS TEST -*COMPUTE TEST2/D12 = NEXT DEALER_COST - DEALER_COST; AS TEST2 BY CAR END
Please let me know if this is something possible in version 8.
Thank you,
MichaelThis message has been edited. Last edited by: <Emily McAllister>,
May 27, 2016, 03:19 PM
MartinY
As far as I know there is no NEXT row. But using the LAST should be possible, it's just a question of processing where you should only have to "invert" your logic.
It is a question of "did I skiped the fence already and have to look behind or will I skip and look after". According to me, it's easier to know what has happened then knowing what is going to happen...
So I'm pretty sure that is feasible with LAST.
WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF In Focus since 2007
May 31, 2016, 08:47 AM
jgelona
There is no NEXT logic. Use of NEXT or LAST logic implies that a time component is either implied or is an explicit part of the order of the data. Just reverse that so the most recent rows are first then you can use LAST. I do it all the time.
In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
May 31, 2016, 09:49 AM
J.L. Hinds
Give this a shot.
TABLE FILE CAR SUM CAR AS 'NXTCAR' COMPUTE LSTCAR/A16=LAST CAR; BY COUNTRY NOPRINT BY CAR NOPRINT ON TABLE SET HOLDLIST PRINTONLY ON TABLE HOLD AS NXTCAR FORMAT FOCUS INDEX LSTCAR END -RUN JOIN CAR IN CAR TO LSTCAR IN NXTCAR -RUN TABLE FILE CAR SUM SALES NXTCAR BY COUNTRY BY CAR END