Skip to main content
Solved

Sort attribute values per feature

  • January 20, 2020
  • 5 replies
  • 182 views

pimververgmail

Sorting happens mostly by one attribute across a set of features. I would like to sort multiple attribute values (all of type datetime) across one feature and pick out the most recent date (of that particular feature) and assign it to a new attribute. I can imagine a lot of complex Testers, but it seems so obvious to use sorting of some kind. Any suggestions?

Best answer by takashi

Hi @pimververgmail, if the dates are sortable format values (e.g. yyyymmdd etc.), you can populate them into a list and then extract min / max values with the ListRangeExtractor.

In order to populate the multiple attribute values into a list attribute, the ListPopulator or the ListExpressionPopulator could be used if the attributes are named with some specific convention, otherwise the AttributeListPopulator from FME Hub could be used.

View original
Did this help you find an answer to your question?

5 replies

sigtill
Supporter
Forum|alt.badge.img+24
  • Supporter
  • January 20, 2020

Can you use a StatisticsCalculator and group by the attributes you want and look at the "highest" date?


Forum|alt.badge.img
  • January 20, 2020

How about a ListBuilder to combine your date attributes, then a ListSorter to get the newest/highest date to become list item {0} and finally a ListIndexer to pick out the date from list item {0} to a new attribute?


david_r
Evangelist
  • January 20, 2020
danullen wrote:

How about a ListBuilder to combine your date attributes, then a ListSorter to get the newest/highest date to become list item {0} and finally a ListIndexer to pick out the date from list item {0} to a new attribute?

That's a good solution that I use quite a lot, just be aware that the ListSorter cannot be used to sort on multiple keys, even when chaining multiple ListSorters, see: https://knowledge.safe.com/content/idea/72018/listsorter-to-support-multiple-sort-by-criteria.html

Also, I usually prefer using the Aggregator as it has more options than the ListBuilder, but of course that's a personal preference.


takashi
Influencer
  • Best Answer
  • January 20, 2020

Hi @pimververgmail, if the dates are sortable format values (e.g. yyyymmdd etc.), you can populate them into a list and then extract min / max values with the ListRangeExtractor.

In order to populate the multiple attribute values into a list attribute, the ListPopulator or the ListExpressionPopulator could be used if the attributes are named with some specific convention, otherwise the AttributeListPopulator from FME Hub could be used.


pimververgmail
takashi wrote:

Hi @pimververgmail, if the dates are sortable format values (e.g. yyyymmdd etc.), you can populate them into a list and then extract min / max values with the ListRangeExtractor.

In order to populate the multiple attribute values into a list attribute, the ListPopulator or the ListExpressionPopulator could be used if the attributes are named with some specific convention, otherwise the AttributeListPopulator from FME Hub could be used.

I tried the AttributeListPopulator, followed by the ListRangeExtractor. Worked like a charm! Thank you!


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings