Question

How to compare and dynamically decide which record to keep?

  • 16 March 2021
  • 3 replies
  • 8 views

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

Userlevel 6
Badge +33

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

workspaceresult 

Badge +3

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

workspaceresult 

Thanks for your help. It works perfectly.

 

 

 

 

Userlevel 1
Badge +21

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

Reply