Focal Point
[CLOSED] TOTAL ON BY FIELDS WITH ACROSS

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

March 05, 2012, 05:00 AM
Cati - France
[CLOSED] TOTAL ON BY FIELDS WITH ACROSS
Hello,

I need to have the total for two fields which are by fields. How can I do this ?
Here is the code, the fields are TOT_PAS and TOT_FAC.
[DEFINE FILE TMP1
TOT_PAS/D6.2 = TOTAL_PAS/60;
TOT_FAC/D6.2 = TOTAL_FAC/60;
END

TABLE FILE TMP1
SUM
COMPUTE HH_PAS/D6.2 = MINUTES_PAS/60; AS 'Tps 1'
COMPUTE HH_FAC/D6.2 = MINUTES_FAC/60; AS 'Tps 2'

BY JOUR NOPRINT
BY PERIODE AS 'Date'
BY TOT_PAS AS 'Tot 1,Jour'
BY TOT_FAC AS 'Tot 2,Jour'
BY COCLI AS 'Client'
ACROSS CTTYPE AS 'Tâches' NOPRINT
ACROSS CYLIB AS 'Détail des Tâches'
]
Thanks for help.
Catherine

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


7.7.02 (Html, Excel, Ahtml, Pdf,Graph,.....)
OS400 V5R3, V5R4
Windows 2000/2003/2007/2010
March 05, 2012, 05:26 AM
Wep5622
Something like this should do the trick:
DEFINE FILE TMP1
 DUMMY/I1 = 0;
END
TABLE FILE TMP1
SUM COMPUTE TOT_PAS/D6.2 = TOTAL_PAS/60;
    COMPUTE TOT_FAC/D6.2 = TOTAL_FAC/60;
BY DUMMY
ON TABLE HOLD AS TMP2 FORMAT FOCUS INDEX DUMMY
END
-RUN

JOIN
 DUMMY WITH JOUR IN TMP1 TO
 DUMMY IN TMP2 AS J0
END
DEFINE FILE TMP1
 DUMMY/I1 WITH JOUR = 0;
END
TABLE FILE TMP1
SUM
 COMPUTE HH_PAS/D6.2 = MINUTES_PAS/60; AS 'Tps 1'
 COMPUTE HH_FAC/D6.2 = MINUTES_FAC/60; AS 'Tps 2'

BY JOUR NOPRINT
BY PERIODE AS 'Date'
BY TOT_PAS AS 'Tot 1,Jour'
BY TOT_FAC AS 'Tot 2,Jour'
BY COCLI AS 'Client'
ACROSS CTTYPE AS 'Tâches' NOPRINT
ACROSS CYLIB AS 'Détail des Tâches'
END



WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
March 05, 2012, 08:22 AM
Danny-SRL
Cati,

The problem with totalling BY fields is twofold:
1. They cannot be totalled directly as they are not verb objects
2. Since you are sorting on them, you probably want to total the distinct values.

So I don't see any other possibility than having more than one pass and also having to use some &variables. Here is what I came up with:
  
-* File CatiFrance5.fex
SET HOLDLIST=PRINTONLY
TABLE FILE CAR
BY COUNTRY
BY SEATS
ON TABLE HOLD
END
TABLE FILE HOLD
SUM SEATS
ON TABLE SAVE
END
-RUN
-READ SAVE,&TSEATS
-RUN
TABLE FILE CAR
SUM RCOST DCOST
BY COUNTRY
BY SEATS
ON TABLE SUBFOOT
"Total<+0 &TSEATS<TOT.RCOST<TOT.DCOST"
ON TABLE SET STYLE *
TYPE=TABFOOTING, HEADALIGN=BODY, JUSTIFY=RIGHT, $
TYPE=TABFOOTING, ITEM=1, JUSTIFY=LEFT, $
ENDSTYLE
END



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