Skip to main content
Hi Folks,

 

Conceptually simple problem:

 

 

I have a collection of features which include two attributes each:

 

 

Unique_ID--- value

 

1  10

 

1  9

 

2  8

 

1  7

 

2  6

 

2  5

 

2  4

 

1  3

 

2  2

 

1  1

 

 

What I want to do is keep only one feature for each Unique_ID, and that feature should be the one with the highest Value.

 

So in the above example, I'd only want to keep:

 

1  10

 

2  8

 

 

I can sort the values to get the above order of features (Sorter), but can't think of how to get FME to discard all features but the one with the largets value.

 

 

(I considered using a variable setter/getter with the Sampler, but the Sampler can't sample based off variables/attributes, only parameters.)

 

 

Any suggestions?

 

Thanks!
Hi Jonathan,

 

 

Of course you can use the Sampler with this setting.

 

Group By: Unique_ID

 

Sampling Type: First N Features

 

Sampling Amount: 1

 

 

Alternatively, the DuplicateRemover can be also used.

 

Key Attributes: Unique_ID

 

Each first feature for every ID group goes to Unique port.

 

 

Takashi
Hi Takashi,

 

I feel quite silly for not considering that. Although I completely missed that there was a GroupBy in the Sampler in the first place tbh.

 

Works great.

 

Many thanks,

 

Jonathan

Reply