Skip to main content
Solved

Sort attribute values per feature

  • January 20, 2020
  • 5 replies
  • 224 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.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

5 replies

sigtill
Supporter
Forum|alt.badge.img+25
  • Supporter
  • 956 replies
  • 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
  • 104 replies
  • 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
Celebrity
  • 8392 replies
  • 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?

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
Celebrity
  • 7843 replies
  • 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
  • Author
  • 2 replies
  • 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.

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