Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Trouble with multiple subtotals on same BY field.

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Trouble with multiple subtotals on same BY field.
 Login/Join
 
Gold member
posted
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
 
Posts: 81 | Location: Calgary, Alberta | Registered: August 07, 2003Report This Post
Guru
posted Hide Post
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.
 
Posts: 346 | Location: Melbourne Australia | Registered: April 15, 2003Report This Post
Gold member
posted Hide Post
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
 
Posts: 81 | Location: Calgary, Alberta | Registered: August 07, 2003Report This Post
Virtuoso
posted Hide Post
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
 
Posts: 995 | Location: Gaithersburg, MD, USA | Registered: May 07, 2003Report This Post
Expert
posted Hide Post
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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Gold member
posted Hide Post
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
 
Posts: 81 | Location: Calgary, Alberta | Registered: August 07, 2003Report This Post
Expert
posted Hide Post
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
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Trouble with multiple subtotals on same BY field.

Copyright © 1996-2020 Information Builders