Focal Point
FML Help - Running Total of Columns

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/5051047192

July 16, 2008, 10:01 AM
Tewy
FML 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


WF 7.6.11
Output: HTML, PDF, Excel
July 17, 2008, 08:48 AM
Danny-SRL
Tewy,

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



Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

July 17, 2008, 10:02 AM
Tewy
Thanks 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.


WF 7.6.11
Output: HTML, PDF, Excel
July 17, 2008, 01:33 PM
Tony A
Tewy,

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



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10