Hi,
1. Make sure every feature does have a unique id
2. Use ListExploder to create features for every list element
(you might want to take a look at 'Conflict Resolution')
3. Use StatisticsCalculator to calculate average value grouped by id
You can get the list average using a ListSummer and a ListElementCounter, followed by an ExpressionEvaluator with something like
@Value(_sum)/@double(@Value(_element_count))
This avoids using the ListExploder, which has a tendency to consume a lot of memory and slow down your translation considerably if you have many features and/or list elements. It also leaves you with the same number of output features and doesn't require a unique ID.
You can get the list average using a ListSummer and a ListElementCounter, followed by an ExpressionEvaluator with something like
@Value(_sum)/@double(@Value(_element_count))
This avoids using the ListExploder, which has a tendency to consume a lot of memory and slow down your translation considerably if you have many features and/or list elements. It also leaves you with the same number of output features and doesn't require a unique ID.
Nice suggestion! I will use this one myself in the future :)
Alternatively I think you can avoid exploding (an rebuilding) the list like this:
- Use a ListElementCounter to count the number of list elements, store that in an attribute (e.g. _elements)
- Use a ListSummer to sum the value of one list attribute, store that in a new attribute (e.g. _sum)
- Your average will be _sum divided _elements
You can get the list average using a ListSummer and a ListElementCounter, followed by an ExpressionEvaluator with something like
@Value(_sum)/@double(@Value(_element_count))
This avoids using the ListExploder, which has a tendency to consume a lot of memory and slow down your translation considerably if you have many features and/or list elements. It also leaves you with the same number of output features and doesn't require a unique ID.
Aaah, you beat me once again... :)
Aaah, you beat me once again... :)
On the other hand, I think your suggestion is a brilliant one
On the other hand, I think your suggestion is a brilliant one ;-)
Almost as brilliant as yours ;)
And yet another option is.....the ListStatisticsCalculator from the FME Hub.
You can get the list average using a ListSummer and a ListElementCounter, followed by an ExpressionEvaluator with something like
@Value(_sum)/@double(@Value(_element_count))
This avoids using the ListExploder, which has a tendency to consume a lot of memory and slow down your translation considerably if you have many features and/or list elements. It also leaves you with the same number of output features and doesn't require a unique ID.
Thanks @jeroenstiers and @david_r , both great suggestions, I went with the latter option as I need this thing to scale up to handle lots of data.
I got to say, FME Knowledge Center is a great resource. I always get multiple good answers, really quickly too!
Thanks for all the help folks!