Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Weighted Averages
Go
New
Search
Notify
Tools
Reply
  
[CLOSED] Weighted Averages
 Login/Join
 
Member
posted
I'm drawing a blank here ..

I need to calc weighted averages based on 2 columns

Amount Return
9,500,000 14.4%
4,750,000 15.0%
3,963,600 22.5%
11,115,000 14.9%
------------------------------------------------
29,328,600 15.77%

I'm sure this is pretty basic, but it's been a while since I've had my WF hat on! I can certainly sum the Amount column, but it's the weighting of the Return that has me stymied.

Each Return value is multiplied by it's corresponding Amount. The sum of these products is then divided by the sum of the Amount column.

A DEFINE? A RECAP? A COMPUTE?

TIA...

This message has been edited. Last edited by: Kerry,
 
Posts: 21 | Location: Springfield, MA | Registered: August 17, 2004Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Yes do some searches on RECAP. Should be what you need.


In Focus since 1993. WebFOCUS 7.7.03 Win 2003
 
Posts: 1903 | Location: San Antonio | Registered: February 28, 2005Reply With QuoteReport This Post
Platinum Member
posted Hide Post
How about this...

TABLE FILE CAR
PRINT
DEALER_COST
RETAIL_COST
COMPUTE MARKUP_PCT/D7.2% = (RETAIL_COST - DEALER_COST) / DEALER_COST * 100;

ON TABLE RECOMPUTE AND SUB-TOTAL
END

Sean


------------------------------------------------------------------------
PROD: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
TEST: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
 
Posts: 210 | Location: Ottawa | Registered: November 03, 2005Reply With QuoteReport This Post
Member
posted Hide Post
Perhaps we're getting close.

What I need to show as the final result is something like this:

Amount (A) Return (B)
------------ ----------
9,500,000 14.4%
4,750,000 15.0%
3,963,600 22.5%
11,115,000 14.9%
----------------------------
29,328,600 (C) 15.77% (D)

(C) is the sum of (A)
(D) is the sum total of each product (A)*(B), which is then divided by (C) to obtain the correct weighted average return. We can't calculate this until the total amount is known. It is similar to how one would calculate this in Excel, using the =SUMPRODUCT() function.

I'll need to brush up on knowing which WF keywords operate on data as it is retrieved vs when all is retrieved.

Thanks, all. Keep the good advice coming!
 
Posts: 21 | Location: Springfield, MA | Registered: August 17, 2004Reply With QuoteReport This Post
Platinum Member
posted Hide Post
I'm not sure how this technique would not solve your problem. You need a formula that is COMPUTEd in the TABLE FILE section, which identifies how your Return is derived.

Then the ON TABLE RECOMPUTE AND SUB-TOTAL will total all of your Amounts, and recalculate a weighted (total) Return based on the COMPUTE formula.

Let me know if I am missing something here.

Sean


------------------------------------------------------------------------
PROD: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
TEST: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
 
Posts: 210 | Location: Ottawa | Registered: November 03, 2005Reply With QuoteReport This Post
Expert
posted Hide Post
i agree with smiths, if B results from a COMPUTE statement in your fex, then ON TABLE SUMMARIZE
or ON fieldname RECOMPUTE
will recrank the proper result.
How is your B determined? Is B static or is it COMPUTEd in your fex?
You would want to COMPUTE your field, and very specifically not DEFINE it; A static, or DEFINEd field won't recompute easily

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




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Reply With QuoteReport This Post
Gold member
posted Hide Post
Hi Bill,

You need a defined field that multiplies A * B, then in your table request, sum the field, and then compute a new field that divides the defined field by A. I have an example if you want to see it.

Jen


Release 5.2.4
Upgrading to 7.6
 
Posts: 68 | Location: Springfield MA | Registered: May 07, 2003Reply With QuoteReport This Post
Member
posted Hide Post
Actually I think your missing a step in the methodology to calculate your weighted average return. The example should be more like the following.

Amount (A)...........Return (B)................... Weight(E) .................. Contribution (F)
----------------------------------------------------------------------------------------------- 9,500,000................14.4%............9,500,000/29,328,600...............0.046644
4,750,000................15.0%............4,750,000/29,328,600...............0.024294
3,963,600................22.5%............3,963,600/29,328,600...............0.030408
11,115,000...............14.9%............11,115,000/29,328,600..............0.056468
--------------------------------------------------------------------------------------------
29,328,600 (C)...............................................................15.77% (D)


D would be the sum of column F, which is E * B. The computed field needs to be the Amount row value divided by the total of column A.

Hope that helps. Sorry about the dots.

This message has been edited. Last edited by: MTracker,
 
Posts: 21 | Registered: November 15, 2004Reply With QuoteReport This Post
Silver Member
posted Hide Post
I have the the same issue, but the result needs to be displayed as

Amount(A).... Return(B)
------------------------
9,500,000 14.4%
4,750,000 15.0%
3,963,600 22.5%
11,115,000 14.9%
------------------------
29,328,500(C) 15.77%(D)

without displaying the Weight(E) and Contribution(F) used for calculations..display (D) in place of total of Return(B) in the same line..

I tried use Subtotal/Recompute nothing seemed to work.. Tried using FML but that decreased the performance drastically..

I there any other way the output can be displayed as above...

Thanks in advance..


Release: Webfocus 7.6.11
OS/Platform: Windows
Output: HTML, EXL2K
 
Posts: 32 | Registered: October 29, 2010Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Weighted Averages

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.