I have Year and Curr Count columns and i am trying to calculate the rest of the column. It looks very simple and i have done something similar using
LAST
command.But now i am not able to bring the Prev Count column.Once i have Prev Count i can calculate diff.But i am stuck in logic to calculate Prev Count.
Any help would be appreciated.This message has been edited. Last edited by: srajeevan,
WF8206,Windows 7,8,10 HTM,PDF,EXCEL
February 01, 2019, 04:17 AM
GamP
You can achieve the desired result by doing it through an intermediate file. First extract the data, sort it by product and year - which will allow your calculations to be performed correctly. Then hold the result and report off that hold file. The simplified example for this would be something like:
TABLE FILE xyzzy
SUM CNTR
COMPUTE PCNTR/I6 = IF PROD NE LAST PROD THEN 0 ELSE LAST CNTR;
COMPUTE DIFF/I6 = CNTR - PCNTR;
BY PROD
BY YEAR
ON TABLE HOLD
END
TABLE FILE HOLD
PRINT CNTR AS 'Curr Count'
PCNTR AS 'Prev Count'
DIFF AS 'Diff'
BY YEAR AS 'Year'
BY PROD AS 'Product'
END
Hope this helps...
GamP
- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
February 01, 2019, 08:42 AM
jgelona
Have you looked at the PARTITION_AGGR and PARTITION_REF functions?
In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
February 04, 2019, 09:21 AM
srajeevan
@GamP : I was able to use your solution.Thanks. @jgelona : I will try to use the functions you mentioned and see if it can help.Thanks.