Focal Point
[CLOSED]SUM is for ?

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

September 05, 2012, 09:08 PM
Pippen
[CLOSED]SUM is for ?
Hi,

I just new to WF have a question about SUM command.

According to the manual, SUM is to add the value, but for below procedure, SUM command only add the SALARY column and did not add the MAX.SALARY or MIN.SALARY

Question is that: you may say that MAX/MIN prefix overwrite the SUM command, I want to know what is the process order and know how to differ the SUM command real meaning?

TABLE FILE EMPLOYEE
SUM
SALARY
MAX.SALARY
MIN.SALARY
BY DEPARTMENT
END

The result is :
PAGE 1
DEPARTMENT-SALARY------MAX SALARY-MIN SALARY
MIS________$160,177.00_$27,062.00_$8,650.00
PRODUCTION_$172,752.00_$29,700.00_$9,050.00

Thanks.

UPDATE:
Thanks for the reply. I know here SUM would aggregate facts with pure columns or columns with prefix operator. This is like SUM COMMAND indicates it is going to do something with the numbers and then check the prefix for further action.

This message has been edited. Last edited by: Pippen,


WebFOCUS 7.7.03, Windows 7 64bit, IE8
September 06, 2012, 03:21 AM
Dave
Sum is a Verb indeed.

But is just says to WF : "You have to do something with all the rows you get belonging to the BY's'.

And if you don't specify... WF will SUM the values.

You could see it as 'CALCULATE'. That would make it clearer for you:

TABLE FILE EMPLOYEE
CALCULATE SUM.SALARY
          MAX.SALARY
          MIN.SALARY
BY DEPARTMENT
END



Btw. SUM doesn't refer to multiple column in the first place. It refers to the ROWS.



Oh... you might want to do a course... ..or 2.


G'luck


_____________________
WF: 8.0.0.9 > going 8.2.0.5
September 06, 2012, 03:22 AM
Alan B
There is no mystery behind MAX/MIN. These are Prefix operators and do what they say on the tin. The documentation for the MAX/MIN prefix operators is clear:

The prefixes MAX. and MIN. produce the maximum and minimum values, respectively, within a sort group. If the request does not include a sort phrase, MAX. and MIN. produce the maximum and minimum values for the entire report.

There are 17 prefix operators to consider.

If you are new to WebFOCUS, then you should undertake some training courses where the trainer will offer any explanation you require.


Alan.
WF 7.705/8.007
September 06, 2012, 05:36 AM
j.gross
Think of SUM as meaning "summarize": collapse values from multiple in-coming rows into a single figure -- as opposed to PRINT or LIST which will produce one line of output per row of input.

There are several ways to summarize the rows, and the prefix operator can be used to specify which one -- produce an arithmetic sum (SUM., the default); count instances (.CNT); maximum value (.MAX), etc.
September 06, 2012, 05:50 AM
Dave
@j.gross true.

But I must say when English isn't your first language 'summarize' sounds a lot like 'the sum of...' ;-)


_____________________
WF: 8.0.0.9 > going 8.2.0.5
September 06, 2012, 06:09 AM
Tony A
I know that you've closed this topic, but the following might help in understanding the prefix operators a little more for others if not for you.

DEFINE FILE CAR
  RCOST_TOT/D12 = RCOST;
END
TABLE FILE CAR
  SUM RCOST_TOT        AS 'Summation'
      MAX.RCOST_TOT    AS 'Maximum'
      MIN.RCOST_TOT    AS 'Minimum'
      CNT.RCOST_TOT    AS 'Count'
   BY COUNTRY          AS 'Country'
 LIST RCOST            AS 'Values'
   BY COUNTRY          AS 'Country'
   BY RCOST_TOT NOPRINT
WHERE COUNTRY NE 'FRANCE'
ON COUNTRY SUBTOTAL RCOST AS 'Total'
ON TABLE NOTOTAL
ON TABLE SET HTMLCSS ON
ON TABLE SET PAGE NOLEAD
ON TABLE SET STYLE *
  grid=on, size=12, $
  type=data, column=RCOST_TOT, color=blue, $
  type=data, column=MAX.RCOST_TOT, color=green, $
  type=data, column=MIN.RCOST_TOT, color=red, $
  type=data, column=RCOST, color=silver, $
  type=data, column=RCOST, color=green, when=RCOST EQ MAX.RCOST_TOT, $
  type=data, column=RCOST, color=red, when=RCOST EQ MIN.RCOST_TOT, $
  type=data, column=LIST, color=silver, $
  type=subtotal, color=silver, $
  type=subtotal, column=RCOST, color=blue, $
ENDSTYLE
END

The output is more important than the actual code.

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