Skip to main content
Question

How to compare and dynamically decide which record to keep?


brandonguo
Contributor
Forum|alt.badge.img+3

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+54

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

workspaceresult 


brandonguo
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • March 16, 2021
nielsgerrits wrote:

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+38
  • Influencer
  • 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


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