Focal Point
help computing totals

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

August 22, 2006, 10:56 AM
.eric
help computing totals
I was trying to get some help computing an average in the totals line (without using RECAP) for my report. I am currently using:
ON TABLE RECOMPUTE AVE. FIELDNAME.

But I need the average to only compare values where it does not equal zero. So if the 5 row values are 0 1 1 1 1 the average should be 1 not .8 .

If this is possible any help would be great, thanks.


dev: WF 7.6.5 w/IIS + Tomcat

prod: WF 7.6.5 w/IIS + Tomcat
August 22, 2006, 04:10 PM
smiths
Eric,

I think this might be the idea you are looking for:

DEFINE FILE CAR
CNT/I4 = IF SALES EQ 0 THEN 0 ELSE SEATS;
END

TABLE FILE CAR
PRINT
COUNTRY
CAR
MODEL
SALES
SEATS 
COMPUTE SOMEAVG/I5 = IF CNT EQ 0 THEN 0 ELSE SALES/CNT;

WHERE COUNTRY EQ 'ITALY'

ON TABLE RECOMPUTE AND SUB-TOTAL

END



Regards,
Sean


------------------------------------------------------------------------
PROD: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
TEST: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
August 22, 2006, 05:08 PM
.eric
I may have said it wrong, but I need column totals for that specific row. The results of the code you posted are (with sales showing an average in the column total instead of summed totals):

COUNTRY CAR MODEL SALES SEATS SOMEAVG
ITALY ALFA ROMEO 2000 4 DOOR BERLINA 4800 4 1200
ITALY ALFA ROMEO 2000 GT VELOCE 12400 2 6200
ITALY ALFA ROMEO 2000 SPIDER VELOCE 13000 2 6500
ITALY MASERATI DORA 2 DOOR 0 2 0
TOTAL 7550 10 3775

Where 7550 is ther average sales of 4800,12400,13000,0. I need that number to say 10066 which is the average of 4800,12400,13000.


dev: WF 7.6.5 w/IIS + Tomcat

prod: WF 7.6.5 w/IIS + Tomcat
August 22, 2006, 05:13 PM
smiths
Then just simplify it to this...

  
DEFINE FILE CAR
CNT/I4 = IF SALES EQ 0 THEN 0 ELSE 1;
END

TABLE FILE CAR
PRINT
COUNTRY
CAR
MODEL
SALES
COMPUTE SOMEAVG/I5 = IF CNT EQ 0 THEN 0 ELSE SALES/CNT;

WHERE COUNTRY EQ 'ITALY'

ON TABLE RECOMPUTE AND SUB-TOTAL

END




------------------------------------------------------------------------
PROD: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
TEST: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
August 24, 2006, 09:36 AM
.eric
It worked, I would never have thought of that ... Thanks smiths!


dev: WF 7.6.5 w/IIS + Tomcat

prod: WF 7.6.5 w/IIS + Tomcat