Skip to main content

I have a workflow involving three readers (Reader 1, Reader 2, and Reader 3), and I need help setting up conditional logic based on feature counts for a given ID.

Here's what I'm trying to achieve:

  1. All three readers are filtered by the same ID.

  2. Condition 1:

    • If both Reader 1 and Reader 2 have at least one feature for the given ID, then do nothing—no features should be written to the writer.
  3. Condition 2:

    • If Reader 1 has at least one feature, but Reader 2 has zero features for the given ID, then:
      • Write the feature from Reader 3 that matches the given ID to the writer.

I'm looking for the best way to implement this logic in FME. 
 

Thanks for any advice or examples!

One way to do this is to use a FeatureMerger to determine if a feature in 1 is also in 2. Then use that result and a second FeatureMerger to get all features from 3 that are in 1 but not in 2.

The first FeatureMerger can also be a ChangeDetector.

Sample attached.


@nielsgerrits 

Thanks for the workbench! I need a bit of guidance on adjusting it for my specific requirements.

In my case, the ID is set as a user parameter, so all three readers (Reader 1, Reader 2, and Reader 3) will be filtered by this ID from the start. Sometimes, Reader 2 may have zero features simply because it doesn't contain any data with the specified ID and then I would like to copy the feature from Reader 3 with same id 


I think you can connect these readers to the connections and they will just work?


@nielsgerrits It does not work because one of the reads has no feature, so it won't be merged with a feature.


@nielsgerrits I am very sorry. I messed up the port. It works!! Thanks a lot


Cheers :)


Reply