Focal Point
Calculate the percentage of a group value from a total sum

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/6641008331

September 28, 2004, 01:55 PM
Alfred
Calculate the percentage of a group value from a total sum
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
September 28, 2004, 02:24 PM
Tewy
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

you can then use this new field for your calculation instead.
October 01, 2004, 05:22 PM
Noreen Redden
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
October 12, 2004, 08:17 AM
Alfred
Thank you to both,
I made it with the criteria in the define section.

Alfred