Question

How to add a new attribute showing an existing attribute as a percentage of that columns total value?


I have a table with integer values as one of the attributes. I need to add an attribute to represent these values as a percentage of the total of these values like in the table below.

have thisneed thisvaluepercentage of total617.64705882411.76470588617.6470588238.82352941225.882352941617.64705882720.58823529

 

I figured ExpressionEvaluator is correct approach but Im pretty new to fme and cant see how it's done. Any help much would be much appreciated,

Rgds


3 replies

Userlevel 1
Badge +21

You need a statistics calculator first to get the sum of the value column, then you can use the expression evaluator to calculate the percentage

Userlevel 2
Badge +16

StatisticsCalculator can calculate the Sum of all values in the "have this" column (use the Complete output port).

Then the "need this" can be calculated in ExpressionEvaluator (or the Arithmetic Editor of AttributeCreator) as 100 * "have this"/Sum.

Hope this helps.

Thanks to you both @erik_jan and @ebygomm for you answers - very helpful - I've got this to work using the statistic calculator now. I'd previously looked at this but was mistakenly using the summary output instead of the complete output so had discounted it. Cheers

Reply