Skip to main content

Hi there,

Here's a sample of what my data looks like:

GroupTypeAxAxAxABxBCxCxCDD

I need to know what the percentage "x" distribution is per Group.

 

A = 75%

B = 50%

C = 66.66%

D = 0%

I was thinking of using a counter grouped by "Group" (If that is possible?) and then using perhaps a expressionevaluator to calculate it, but I'm not quite sure how to go about it.

Any ideas?

Hi @robbie_botha, there should be many ways. Just an idea. Assuming that the "Type" always has a single character (e.g. 'x') or empty.


I would use a attributeCreator with a conditional expression, if Type = x, set the _temp attribute to 1, otherwise, set it to 0.

 

 

Then use a StatisticsCalculator, group by Group, attribute to analyse _temp, and the two relevant statistics are _sum and _count. _sum/_count*100 will give you the percentage.

 

 

This has the benefit of being flexible, the conditional can be as complicated as necessary, and you have the choice of the summary output, one feature per group, or the complete output, in which every original feature will have the attributes.


Reply