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     [SOLVED] Catch 22 with SUBTOTAL and RECOMPUTE

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Catch 22 with SUBTOTAL and RECOMPUTE
 Login/Join
 
Gold member
posted
I have a procedure where I want to subtotal some columns at a particular sort level so I used SUBTOTAL. Some of the columns are directly from the database and they are subtotaled correctly. Some of the rows are computed values and they are subtotaled correctly. One of the rows is subtotaled incorrectly since that column a margin value and it is adding it up (this is like an average so it should not be added - it should be recalculated). Changed SUBTOTAL to RECOMPUTE to correct this and it did for that row and also the other rows that came directly from the database but the rows that are computed values are all way to high (not subtotaled correctly). I can't seem to get this to work althought I've tried 50 combinations of SUBTOTAL and RECOMPUTE. I guess what I'd like to do is SUBTOTAL some rows and RECOMPUTE others but it seems that the RECOMPUTE overrides the SUBTOTAL or maybe that's a coincedence. Any ideas?

TABLE FILE EISBOD
PRINT
ORD AS 'Order'
PRS7/P8C AS 'Pairs'
VALSOLD/P10C AS 'Total Sales'
COMPUTE TOTALSOLDEXT/D10C = SP * PRS7; NOPRINT
COMPUTE TOTALCOSTEXT/D10C = ( TOTSTDCST * PRS7 ); AS 'Total Cost'
COMPUTE TOTALMARGIN/D10C = ( ( SP - TOTSTDCST ) * PRS7 );
AS 'Total Margin'
COMPUTE MarginPct/D7.2% = ( ( TOTALSOLDEXT - TOTALCOSTEXT ) / TOTALSOLDEXT ) * 100;
AS 'Margin%'
BY CUSTNAME AS 'Customer'
BY LOGOP AS 'Logo'
BY PAT AS 'Product'
BY ACS AS 'FOB'
BY TOTSTDCST AS 'Landed'
BY SP AS 'Selling Price'
BY TOTAL COMPUTE MarginPrice/D7.4 = SP - TOTSTDCST; AS 'Margin/Price'

ON CUSTNAME SUBTOTAL AS '*TOTAL '

ON LOGOP SUBTOTAL AS '*TOTAL'
HEADING
"Margin By Pattern"
ON TABLE SUBFOOT
" "
"&DATEMDYY<+0> <+0>&TOD<+0> <+0>&FOCFEXNAME"
WHERE TOTSTDCST NE 0;
WHERE COMP EQ &Company.(FIND COMP IN EISBOD).Company.;
WHERE SLSNAME EQ '&SalesmanName.(FIND SLSNAME IN EISBOD).Salesman Name.';
WHERE RPTDATE GE '&FromDate.From Date.';
WHERE RPTDATE LE '&ThruDate.Thru Date.';
WHERE LF EQ '&LF.(OR(FIND LF IN EISBOD)).LF.';
WHERE STSCD EQ '&StsCd.(OR(FIND STSCD IN EISBOD)).Status Code.';
ON TABLE SET PAGE-NUM OFF
ON TABLE SET POPUPDESC ON
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML



The column titled "Margin %' is the row I need recomputed.

The column titled "Total Cost" is an example of a subtotal that gives a way high number when RECOMPUTE used.

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


________________________________________________________________________________________
WebFOCUS 7.6.8 + Windows Server 2003 + DB2/400
 
Posts: 66 | Location: Nashville, TN, USA | Registered: January 16, 2008Report This Post
Virtuoso
posted Hide Post
I didn't go through your example carefully, but will when I get a minute. Have you tried SUMMARIZE to see if you get what you need?


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
 
Posts: 2298 | Location: Salt Lake City, Utah | Registered: February 02, 2007Report This Post
Gold member
posted Hide Post
How high is "too high" ?
Can you tell what it IS doing with it ? For example, does it look more like a "GRAND TOTAL" ?

You may be able to bury them both in DEFINE statements, or functions, to make them appear the same way to either "SUBTOTL" or "SUMMARIZE" or "RECOMPUTE" ?

Hope this helps ...


WF 7.6.4 & 5.3
Charles Lee
 
Posts: 93 | Registered: June 17, 2008Report This Post
Virtuoso
posted Hide Post
quote:
COMPUTE TOTALSOLDEXT/D10C = SP * PRS7; NOPRINT
COMPUTE TOTALCOSTEXT/D10C = ( TOTSTDCST * PRS7 ); AS 'Total Cost'
COMPUTE TOTALMARGIN/D10C = ( ( SP - TOTSTDCST ) * PRS7 );


SP and TOTSTDCST are rates, are defined at the lowest sort level. But since they do not involve a COMPUTE formula, the values used in the COMPUTEs are the sum of their detail values.

Try using a ratio in these computes, something like
COMPUTE ONE/I5=1; NOPRINT
COMPUTE SP1/D12.2 = SP/ONE; NOPRINT
COMPUTE TOTSTDCST1/D12.2 = TOTSTDCST/ONE; NOPRINT
COMPUTE TOTALSOLDEXT/D10C = SP1 * PRS7; NOPRINT
COMPUTE TOTALCOSTEXT/D10C = ( TOTSTDCST1 * PRS7 ); AS 'Total Cost'
COMPUTE TOTALMARGIN/D10C = ( ( SP1 - TOTSTDCST1 ) * PRS7 );


SP1 will equal SP at the original COMPUT level, but in the rollup RECOMPUTEs it will be a weighted average.


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Virtuoso
posted Hide Post
JD,
SUBTOTAL and RECOMPUTE are exclusive and if you use both the last operation will prevail. Your only option is to use SUBFOOT and a RECAP for the recalculation of your "margin". See an example using the CAR file:

  
TABLE FILE CAR
PRINT 
     RETAIL_COST
     DEALER_COST
     SALES
     COMPUTE PROFIT/D9 = SALES * ( RCOST - DCOST );
     COMPUTE RATIO/F6.2 = DCOST / RCOST;
BY COUNTRY
BY CAR
     
ON COUNTRY RECAP 
CRATIO/F6.2 = DCOST / RCOST;
ON COUNTRY SUBFOOT
"Total <COUNTRY<ST.RCOST<ST.DCOST<ST.SALES<ST.PROFIT<CRATIO"
ON TABLE NOTOTAL
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
     UNITS=IN,
     SQUEEZE=ON,
     ORIENTATION=PORTRAIT,
$
TYPE=REPORT,
     GRID=ON,
     FONT='TIMES NEW ROMAN',
     SIZE=10,
$
TYPE=SUBFOOT, HEADALIGN=BODY, JUSTIFY=RIGHT, $
TYPE=SUBFOOT, ITEM=1, JUSTIFY=LEFT, $
TYPE=SUBFOOT, ITEM=2, JUSTIFY=LEFT, $
ENDSTYLE
END


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

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
Virtuoso
posted Hide Post
Since you are PRINTING all the lines, I would put the computed fields in a DEFINE first.
COMPUTE in the TABLE is only necessary if you working with SUM.
The last suggestion from Danny should do the job.




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Gold member
posted Hide Post
Thanks for all of the replies. I will work through each of them and report back on the results.


________________________________________________________________________________________
WebFOCUS 7.6.8 + Windows Server 2003 + DB2/400
 
Posts: 66 | Location: Nashville, TN, USA | Registered: January 16, 2008Report This Post
Gold member
posted Hide Post
quote:
Originally posted by JDroke:
Thanks for all of the replies. Removing the COMPUTES and using DEFINES fixed my problem.


________________________________________________________________________________________
WebFOCUS 7.6.8 + Windows Server 2003 + DB2/400
 
Posts: 66 | Location: Nashville, TN, USA | Registered: January 16, 2008Report 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     [SOLVED] Catch 22 with SUBTOTAL and RECOMPUTE

Copyright © 1996-2020 Information Builders