Skip to main content
Question

How to compare and dynamically decide which record to keep?

  • March 16, 2021
  • 3 replies
  • 60 views

brandonguo
Contributor
Forum|alt.badge.img+4

I have two tables, they have the unique ID to compare with each other. There is another column called year in both tables.

I am hoping to find records in table2 with the same ID in table1 and then compare the 'year' attribute, only keep the latest one.

Which transformer should I use? The feature joiner can find all records in table 2, but it can't dynamically decide which one to keep.

 Screenshot 2021-03-16 121032

3 replies

nielsgerrits
VIP
Forum|alt.badge.img+60
  • 2940 replies
  • March 16, 2021

One way to do this is using the StatisticsCalculator. Group by ID, max Year.

workspaceresult 


brandonguo
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • 45 replies
  • March 16, 2021

One way to do this is using the StatisticsCalculator. Group by ID, max Year.

workspaceresult 

Thanks for your help. It works perfectly.

 

 

 

 


ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3435 replies
  • March 16, 2021

You could also use a sorter followed by a duplicatefilter

Sort on Year in Descending order, then a duplicatefilter with the Key attribute set to ID. The features with the latest year will exit via the unique port