Skip to main content
Question

Select highest value from 1 column using and ID from another column

  • January 29, 2020
  • 7 replies
  • 242 views

Forum|alt.badge.img

I need to build something in FME where it automatically selects all ID entries and then looks at another column with values and selects the row with the highest value, and delete the other rows with the same ID. in the screenshot i have 2 columns: Risicoprofiel_BEREK and ID, in ID there are multiple entries which i need to select and then find the highest value from the Risicoprofiel_BEREK column.

 

7 replies

ebygomm
Influencer
Forum|alt.badge.img+38
  • Influencer
  • January 29, 2020

You can sort by Risicoprofiel_BEREK in descending order and then use a duplicatefilter with a Key attribute of ID to just keep the row with the highest value.


erik_jan
Contributor
Forum|alt.badge.img+18
  • Contributor
  • January 29, 2020

I would go this way:

Use the Sorter transformer to sort by ID and Risicoprofiel_BEREK (descending)

Then use the Sampler (Sample first 1) and group by ID.

The sampled output port will give you the result you need.

Hope this helps.


mark2atsafe
Safer
Forum|alt.badge.img+44
  • Safer
  • January 29, 2020

The simplest method would be to sort the data with a Sorter transformer (sort by Risicoprofiel_BEREK) and then a DuplicateFilter (filter by ID). Then the ID with the highest Risicoprofiel number will pass and the rest are discarded.

As long as you don't mind the records being in a different order, then that would work fine.


mark2atsafe
Safer
Forum|alt.badge.img+44
  • Safer
  • January 29, 2020

Three answers in five minutes all giving the same solution (more or less). I guess it really must be the right way to go!


Forum|alt.badge.img
  • Author
  • January 30, 2020

thanx for your help guys... i got it working! :)


Forum|alt.badge.img
  • Author
  • January 30, 2020
mark2atsafe wrote:

The simplest method would be to sort the data with a Sorter transformer (sort by Risicoprofiel_BEREK) and then a DuplicateFilter (filter by ID). Then the ID with the highest Risicoprofiel number will pass and the rest are discarded.

As long as you don't mind the records being in a different order, then that would work fine.

will this also work if there are like 3 or 4 entries with the same ID? it will always take the highest?


ebygomm
Influencer
Forum|alt.badge.img+38
  • Influencer
  • January 30, 2020
fvierland wrote:

will this also work if there are like 3 or 4 entries with the same ID? it will always take the highest?

Yes, as long as they are sorted from highest to lowest, the first feature with each ID, i.e. the highest, will always be kept


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