Let's Get Social!
Focal Point    Focal Point Forums    WebFOCUS/FOCUS Forum on Focal Point     Calculate the percentage of a group value from a total sum
 Go New Search Notify Tools Reply
 Calculate the percentage of a group value from a total sum
Member
 posted September 28, 2004 01:55 PM
How can I compute the percentage of a group value from the hole dataset when the fex has a where condition and not showing the hole data. Maybe I have to execute an extra fex before which calculates the sum of all values an pass the result to a variable. As well how can I put the results in an extra line before the sub-total

..Field_A......Field_B....Field_C
Sub-Total........10.........500
%of Total........10%........50%..wanted Result
fex with "where (Field A EQ yyy);"

Total of the hole dataset is Field B = 100 and Field C = 1000

Can somebody help me, thanks
Alfred

 Posts: 12 | Location: Linz, Austria | Registered: February 03, 2004 IP
Platinum Member
 posted September 28, 2004 02:24 PM Hide Post
Simple answer is you can't unless you do one of the following.

Either create a holdfile with the total values in it, and join that hold file to your holdfile with the data extracted using your WHERE statement and then calculate your percentage.

Or remove your WHERE criteria and put them in a define. E.g.
DEFINE FILE filename
FIELDA/I5=IF FIELDA EQ 'xyz' THEN FIELDA ELSE 0;
END

 Posts: 123 | Location: UK | Registered: October 09, 2003 IP
Gold member
 posted October 01, 2004 05:22 PM Hide Post
Never say never. <grin> Let everything into the report,and then eliminate by WHERE TOTAL. In my case, I'm using CAR, and only BODYTYPE = sedan is to show on the report:
TABLE FILE CAR
SUM PCT.SALES NOPRINT PCT.RCOST NOPRINT
PCT.DCOST NOPRINT BY BODYTYPE
ON BODYTYPE SUBFOOT
"TOTAL <ST.SALES> <ST.RCOST> <ST.DCOST>"
"PCT <PCT.SALES> <PCT.RCOST> <PCT.DCOST></1"
PRINT SALES RCOST DCOST BODYTYPE NOPRINT
BY BODYTYPE
WHERE TOTAL BODYTYPE EQ 'SEDAN'
END

 Posts: 60 | Location: 2 penn | Registered: May 22, 2003 IP
Member
 posted October 12, 2004 08:17 AM Hide Post
Thank you to both,
I made it with the criteria in the define section.

Alfred

 Posts: 12 | Location: Linz, Austria | Registered: February 03, 2004 IP