July 16, 2008, 10:01 AM
TewyFML Help - Running Total of Columns
I am trying to rebuild a report that was created in excel in WebFOCUS.
The report contains 26 weeks of data, each in a different field. I am trying to use FML to calculate some values with this data, one of which is a running average of the total (i.e. the current weeks value plus all preceding weeks divided by the number of weeks).
Is there an easier way of doing this than:
RECAP TST0(1)=L4; OVER
RECAP TST0(2)=(L4(1)+L4(2))/2; OVER
RECAP TST0(3)=(L4(1)+L4(2)+L4(3))/3; OVER
July 17, 2008, 08:48 AM
Danny-SRLTewy,
Nobody seems to have picked up the gauntlet. Would you care to run the following? It might be your answer without having to use FML:
-* File Tewy.fex
TABLE FILE CAR
PRINT SALES
COMPUTE ACCSALES/I7=SALES + ACCSALES;
COMPUTE NUM/I3=1 + NUM;
COMPUTE RUNAVESALE/I5=ACCSALES / NUM;
BY COUNTRY BY CAR BY MODEL
END
July 17, 2008, 10:02 AM
TewyThanks for the suggestion, but as I'm doing some other calculations I need to use FML.
I have now individually coded each of the 26 weeks (yawn), but thought there must be an easier way.
I'm new to FML so can't help wondering if I'm doing things the long way.
July 17, 2008, 01:33 PM
Tony ATewy,
In the RECAP syntax you can use label(start,end,step) with the subsequent code specifying offsets, it's something like -
RECAP TST0(1,3,1) = (L4(*-1) + L4(*)) / 2; OVER
Search for "Performing Inter-Row Calculations" or "Recursive" in the manual or something similar. I don't have the manual with me at home.
T