Skip to main content
Solved

Keeping the first entry of a list.

  • March 4, 2014
  • 2 replies
  • 690 views

fmelizard
Safer
Forum|alt.badge.img+21
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!

Best answer by takashi

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
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.

2 replies

takashi
Celebrity
  • Best Answer
  • March 4, 2014
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

fmelizard
Safer
Forum|alt.badge.img+21
  • Author
  • Safer
  • March 5, 2014
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