September 28, 2004, 01:55 PMAlfred
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
%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
September 28, 2004, 02:24 PMTewy
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;
you can then use this new field for your calculation instead.
October 01, 2004, 05:22 PMNoreen 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
WHERE TOTAL BODYTYPE EQ 'SEDAN'
October 12, 2004, 08:17 AMAlfred
Thank you to both,
I made it with the criteria in the define section.