Focal Point
Trouble with multiple subtotals on same BY field.

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

October 02, 2006, 06:13 PM
Nightowl
Trouble with multiple subtotals on same BY field.
I have an example where I need three subtotal rows on the same BY field. I will try to illustrate with a Car/Sales model. I have two Salesman (Bob and Fred) who each sell two types of cars in three types of colours in three countries. Here is the report output I need:
Bob             Red    Green   Blue
Jaguar  USA     100     150    100
        CAN      90     100     80 
        MEX      80     125     90
Audi    USA     200     100    200
        CAN     250     200    100
        MEX     150     250    150 

Bob Total USA   300     250    300
Bob Total CAN   340     300    180
Bob Total MEX   230     375    240

Fred             Red    Green   Blue
Jaguar  USA     150     200    150
        CAN     200     100    150
        MEX     175     200    200
Audi    USA     150     150    200
        CAN     250     200    175
        MEX     125     200    225

Fred Total USA  300     350    350
Fred Total CAN  450     300    325
Fred Total USA  300     400    375


I have everything working except the subtotals.
I thought,
ON SALESMAN_NAME SUBTOTAL AS 'USA' WHEN ROW_TYPE EQ 'USA'
would work but it just subtotals all countries for each salesman.

I need three subtotals for each salesman showing total sales for each of the three countries.

Many thanks!


Using: WF 7.1.5, XP Pro, Tomcat, Self Serve
October 03, 2006, 01:49 AM
Piipster
I expect you can see where I'm going with this....


DEFINE FILE CARDATA
RED_CAN/I5 = IF COLOUR EQ 'Red' AND COUNTRY EQ 'CAN' THEN CAR_NUM ELSE 0;
GREEN_CAN/I5 = IF COLOUR EQ 'Green' AND COUNTRY EQ 'CAN' THEN CAR_NUM ELSE 0;
BLUE_CAN/I5 = IF COLOUR EQ 'Blue' AND COUNTRY EQ 'CAN' THEN CAR_NUM ELSE 0;
RED_USA/I5 = IF COLOUR EQ 'Red' AND COUNTRY EQ 'USA' THEN CAR_NUM ELSE 0;
GREEN_USA/I5 = IF COLOUR EQ 'Green' AND COUNTRY EQ 'USA' THEN CAR_NUM ELSE 0;
BLUE_USA/I5 = IF COLOUR EQ 'Blue' AND COUNTRY EQ 'USA' THEN CAR_NUM ELSE 0;

END
TABLE FILE CARDATA
SUM
RED_CAN NOPRINT
GREEN_CAN NOPRINT
BLUE_CAN NOPRINT

RED_USA NOPRINT
GREEN_USA NOPRINT
BLUE_USA NOPRINT
BY NAME


SUM
CAR_NUM AS ''
BY NAME AS ''
BY CAR AS ''
BY COUNTRY AS ''
ACROSS COLOUR AS ''

ON NAME SUBFOOT
"<NAME Total CAN <BLUE_CAN <GREEN_CAN <RED_CAN "
"<NAME Total USA <BLUE_USA <GREEN_USA <RED_USA "
" "
ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML


ttfn, kp


Access to most releases from R52x, on multiple platforms.
October 03, 2006, 11:30 AM
Nightowl
Ah kp, I see where you are going Wink
Trouble is I did not want to hard code counters for each colour. If I add a colour then I have to change my code Frowner


Using: WF 7.1.5, XP Pro, Tomcat, Self Serve
October 03, 2006, 12:12 PM
mgrackin
Try the following:

DEFINE FILE CAR
CNTR/I2 WITH BODYTYPE=IF LAST CNTR EQ 3 THEN 1 ELSE LAST CNTR + 1;
SALESMAN/A12=DECODE CNTR(1 'BOB' 2 'FRED' 3 'KIM');
END
TABLE FILE CAR
SUM SALES
BY SALESMAN
BY COUNTRY
ON TABLE HOLD AS CNTYSALE
END
TABLE FILE CAR
SUM SALES
BY SALESMAN
BY SEATS
BY COUNTRY
ON TABLE HOLD AS BODYSALE
END
DEFINE FILE CNTYSALE
SEATS/I3=999;
SORTCNTL/I1=1;
DISPLAY/A25=SALESMAN | ' Total For';
END
DEFINE FILE BODYSALE
SORTCNTL/I1=0;
DISPLAY/A25='Seats: ' | EDIT(SEATS);
END
TABLE FILE CNTYSALE
PRINT SALES
BY SALESMAN
BY SORTCNTL NOPRINT
BY SEATS NOPRINT
BY DISPLAY
BY COUNTRY
ON SALESMAN SUBFOOT
" "
ON SEATS SUBHEAD
" "
WHEN SEATS EQ 999;
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
TYPE=REPORT, BORDER=LIGHT,$
ENDSTYLE
MORE
FILE BODYSALE
END


Thanks!

Mickey

FOCUS/WebFOCUS 1990 - 2011
October 03, 2006, 12:34 PM
Francis Mariani
Mickey, very elegant!


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
October 03, 2006, 02:03 PM
Nightowl
Sweet sweet sweet, that's all I can say. I'll see if I can apply that to my real world example. Thanks so much Mickey!

Using that example, I would need the seats as across values so that they get totalled as well.

I really need a command as follows:
ON SALESMAN_NAME SUBTOTAL BY COUNTRY
would be the ultimate solution so that each salesman would have three subtotal rows. One for each country.

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


Using: WF 7.1.5, XP Pro, Tomcat, Self Serve
October 04, 2006, 10:40 AM
susannah
that trick Mickey shows of appending a Total group to a Detail group using the MORE command is a very cool way of adding a total line to a gridless report WITHOUT that dreaded blank line in between data and total.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID