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]across percentage recalculation

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED]across percentage recalculation
 Login/Join
 
Gold member
posted
Hello,

Here is a simple example
TABLE FILE CAR
SUM
SALES AS 'Somme'
PCT.SALES/D9.2% WITHIN TABLE WITHIN CAR AS '%'
BY COUNTRY
ACROSS CAR AS '' RECOMPUTE AS 'Totaux'
WHERE CAR LE 'F';

ON TABLE COLUMN-TOTAL AS 'TOTAL'
ON TABLE PCHOLD FORMAT HTML
END

If you run this example, you will see something like this
PAGE 1
ALFA ROMEO AUDI BMW DATSUN Totaux
COUNTRY Somme % Somme % Somme % Somme % Somme %
ITALY 30200 100,00% . . . . . . 30200 100,00%
JAPAN . . . . . . 43000 100,00% 43000 100,00%
W GERMANY . . 7800 100,00% 80390 100,00% . . 88190 200,00%
TOTAL 30200 100,00% 7800 100,00% 80390 100,00% 43000 100,00% 161390 400,00%

what I want for the last column is
First line ==> not 100% but 30200/161390 = 18,71%
Second line ==> not 100% but 43000/161390 = 26,64%
Third line ==> not 200% but 88190/161390 = 54,54 %
Last line ==> not 400% but 100%

How can I have this result ?
Thanks
Catherine

This message has been edited. Last edited by: Cati - France,


7.7.02 (Html, Excel, Ahtml, Pdf,Graph,.....)
OS400 V5R3, V5R4
Windows 2000/2003/2007/2010
 
Posts: 68 | Location: France | Registered: February 27, 2008Report This Post
Expert
posted Hide Post
It's funny/sad that you ask this question right now! I had a problem with this in 2005 and I still have a problem, please see [ALWAYS OPEN] Calculating Percentages with Across and By. I don't think this will help you with the Totals...


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
Virtuoso
posted Hide Post
Here's one approach - a little cumbersome, but it works.

SET ASNAMES  = ON
SET HOLDLIST = PRINTONLY

DEFINE FILE CAR
 CARTEXT/A17    = ' ' | CAR ;
 TOTCARTEXT/A17 = 'TOTAUX';
END

TABLE FILE CAR
 SUM SALES/D9
 BY COUNTRY
 BY CARTEXT AS 'CAR'
 WHERE CAR LE 'F';
 ON TABLE HOLD AS CARHOLD FORMAT ALPHA
END

APP FILEDEF CARHOLD DISK CARHOLD.FTM (APPEND

TABLE FILE CAR
 SUM SALES/D9
 BY COUNTRY
 BY TOTCARTEXT AS 'CAR'
 WHERE CAR LE 'F';
 ON TABLE SAVE AS CARHOLD
END

TABLE FILE CARHOLD
 SUM SALES AS 'Somme'
     PCT.SALES/D9.2% AS '%'
 BY COUNTRY
 ACROSS CAR AS ''
 ON TABLE COLUMN-TOTAL AS 'TOTAUX'
 ON TABLE PCHOLD FORMAT HTML
END


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Platinum Member
posted Hide Post
Try this,
DEFINE FILE CAR
TOTALSALES=SALES;
CNTRYSALES=SALES;
END
TABLE FILE CAR
SUM
TOTALSALES NOPRINT

SUM
CNTRYSALES NOPRINT
BY COUNTRY
SUM
SALES AS 'Somme'
COMPUTE PCT_SALES/D9.2% = SALES/CNTRYSALES*100; AS '%'

BY COUNTRY
ACROSS CAR AS ''
COMPUTE ROWTOT=C2;
ROWPCT=C2/C1*100;

IF CAR LE 'F'

ON TABLE COLUMN-TOTAL AS 'TOTAL'
END
 
Posts: 140 | Location: Adelaide South Australia | Registered: October 27, 2006Report This Post
Gold member
posted Hide Post
Thanks everybody for your answers.

Dan, your solution is OK for the total column but not for each across column because each % column is 100% and that's not what I want.
For example, for W GERMANY SALES : for AUDI, SALES is equal to 7800 so I would have 7800/161390 = 4,83 %; for BMW, SALES is equal to 80390 so I would have 80390/161390 = 49.81 % - the total column of 88190 is OK (54,64%)


I've completed Dan's example to be like what I really need, with several fields for % calcultation and several BY.

SET ASNAMES = ON
SET HOLDLIST = PRINTONLY

DEFINE FILE CAR
CARTEXT/A17 = ' ' | CAR ;
TOTCARTEXT/A17 = 'TOTAUX';
END

TABLE FILE CAR
SUM SALES/D9
DEALER_COST/D9
BY COUNTRY
BY SEATS
BY CARTEXT AS 'CAR'
WHERE CAR LE 'F';
ON TABLE HOLD AS CARHOLD FORMAT ALPHA
END
APP FILEDEF CARHOLD DISK CARHOLD.FTM (APPEND

TABLE FILE CAR
SUM SALES/D9
DEALER_COST/D9
BY COUNTRY
BY SEATS
BY TOTCARTEXT AS 'CAR'
WHERE CAR LE 'F';
ON TABLE SAVE AS CARHOLD
END

TABLE FILE CARHOLD
SUM SALES AS 'Somme'
DEALER_COST AS 'Test'
PCT.SALES/D9.2% AS '%'
PCT.DEALER_COST/D9.2% AS '%'
BY COUNTRY
BY SEATS
ACROSS CAR AS ''
ON TABLE COLUMN-TOTAL AS 'TOTAUX'
ON TABLE PCHOLD FORMAT HTML
END

When you run this, the % are not calculated based on each total.
How do I do that ?

Thanks in advance for taking time to answer to my question.
Catherine

This message has been edited. Last edited by: Cati - France,


7.7.02 (Html, Excel, Ahtml, Pdf,Graph,.....)
OS400 V5R3, V5R4
Windows 2000/2003/2007/2010
 
Posts: 68 | Location: France | Registered: February 27, 2008Report This Post
Gold member
posted Hide Post
Here is the solution given by the french IBI support.
It's exactly what I need.
May interest some of you.
Catherine

SET ASNAMES = ON
SET HOLDLIST = PRINTONLY

DEFINE FILE CAR
CARTEXT/A17 = ' ' | CAR ;
TOTCARTEXT/A17 = 'TOTAUX';
END

TABLE FILE CAR
SUM
COMPUTE SSALES/D12.2 = SALES ;
COMPUTE SDC/D12.2 = DEALER_COST ;

SUM SALES/D9
DEALER_COST/D9
BY COUNTRY
BY SEATS
BY CARTEXT AS 'CAR'
WHERE CAR LE 'F';
ON TABLE HOLD AS CARHOLD FORMAT ALPHA
END
APP FILEDEF CARHOLD DISK CARHOLD.FTM (APPEND

TABLE FILE CAR
SUM
COMPUTE SSALES/D12.2 = 0 ;
COMPUTE SDC/D12.2 = 0 ;
SUM SALES/D9
DEALER_COST/D9
BY COUNTRY
BY SEATS
BY TOTCARTEXT AS 'CAR'
WHERE CAR LE 'F';
ON TABLE SAVE AS CARHOLD
END

TABLE FILE CARHOLD
SUM SALES AS 'Somme'
DEALER_COST AS 'Test'
COMPUTE PSALES/D9.2% = IF CAR NE 'TOTAUX' THEN ( SALES / SSALES ) * 100 ELSE PCT.SALES;
COMPUTE PDC/D9.2% = IF CAR NE 'TOTAUX' THEN ( DEALER_COST / SDC ) * 100 ELSE PCT.DEALER_COST;
BY COUNTRY
BY SEATS
ACROSS CAR AS ''
ON TABLE COLUMN-TOTAL AS 'TOTAUX'
ON TABLE PCHOLD FORMAT HTML
END


7.7.02 (Html, Excel, Ahtml, Pdf,Graph,.....)
OS400 V5R3, V5R4
Windows 2000/2003/2007/2010
 
Posts: 68 | Location: France | Registered: February 27, 2008Report This Post
Virtuoso
posted Hide Post
Or this:

SET ASNAMES = ON
SET HOLDLIST = PRINTONLY

DEFINE FILE CAR
 CARTEXT/A17    = ' ' | CAR ;
 TOTCARTEXT/A17 = 'TOTAUX';
 TOTSALES/D9    = SALES ;
 TOTDLCOST/D9   = DEALER_COST ;
END

TABLE FILE CAR
 SUM TOTSALES
     TOTDLCOST
 SUM SALES/D9
     DEALER_COST/D9
 BY COUNTRY
 BY SEATS
 BY CARTEXT AS 'CAR'
 WHERE CAR LE 'F';
 ON TABLE HOLD AS CARHOLD FORMAT ALPHA
END

APP FILEDEF CARHOLD DISK CARHOLD.FTM (APPEND

TABLE FILE CAR
 SUM TOTSALES
     TOTDLCOST
 SUM SALES/D9
     DEALER_COST/D9
 BY COUNTRY
 BY SEATS
 BY TOTCARTEXT AS 'CAR'
 WHERE CAR LE 'F';
 ON TABLE SAVE AS CARHOLD
END

TABLE FILE CARHOLD
 SUM SALES AS 'Somme'
     COMPUTE PCT_SALES/D9.2%  = SALES / TOTSALES * 100 ; AS '%'
     DEALER_COST AS 'Test'
     COMPUTE PCT_DLCOST/D9.2% = DEALER_COST / TOTDLCOST * 100 ; AS '%'
 BY COUNTRY
 BY SEATS
 ACROSS CAR AS ''
 ON TABLE COLUMN-TOTAL AS 'TOTAUX'
 ON TABLE PCHOLD FORMAT HTML
END


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report 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]across percentage recalculation

Copyright © 1996-2020 Information Builders