Skip to main content
Solved

Keeping the first entry of a list.


fmelizard
Safer
Forum|alt.badge.img+18
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
View original
Did this help you find an answer to your question?
This post is closed to further activity.
It may be a question with a best answer, an implemented idea, or just a post needing no comment.
If you have a follow-up or related question, 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
Influencer
  • 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+18
  • 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

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