Skip to main content
Solved

How do I read the number of records produced from a transformer and use that number in a Cloner Transformer (not directly connected)?

  • March 13, 2016
  • 4 replies
  • 141 views

How do I read the number of records produced from a transformer and use that number in a Cloner Transformer (not directly connected)?

I can grab the number via the Statistics Transformer. However I cannot set the number in the Cloner. Ideally I would add the number as an attribute for all records (in the data going into the Cloner). However I cannot work out how to do this.

Note that I am dealing with 2 completely different sets of data here. The first has the record count. The other data set I want to clone based on the firsts record count.

Thanks for any help I can get.

Best answer by takashi

Hi @jiphoc, save the number of features from the first dataset as a global variable using the VariableSetter, and then give the number to the features from the second dataset as a new attribute using the VariableRetriever.

Note that FME has to read the first dataset before the second dataset. Make sure that the reader for the first dataset is located upper than the second reader in the Navigator window.

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.

4 replies

takashi
Celebrity
  • Best Answer
  • March 13, 2016

Hi @jiphoc, save the number of features from the first dataset as a global variable using the VariableSetter, and then give the number to the features from the second dataset as a new attribute using the VariableRetriever.

Note that FME has to read the first dataset before the second dataset. Make sure that the reader for the first dataset is located upper than the second reader in the Navigator window.


takashi
Celebrity
  • March 13, 2016

Hi @jiphoc, save the number of features from the first dataset as a global variable using the VariableSetter, and then give the number to the features from the second dataset as a new attribute using the VariableRetriever.

Note that FME has to read the first dataset before the second dataset. Make sure that the reader for the first dataset is located upper than the second reader in the Navigator window.

Alternatively you can use the FeatureMerger to merge the number of records (an attribute of the feature from the Summary port of the StatisticsCalculator) to every feature from the second dataset unconditionally. If you set an identical constant (e.g. 1) to the "Join On" parameter for both Requestor and Supplier, attributes of the supplier feature will be merged to every requestor feature unconditionally.


  • Author
  • March 14, 2016

Champion Takashi,

I way playing around with the Variable Setter/ Retriever. I suspect, as you mentioned, the correct data being ready first may be causing me problems. I just figured a purpose built built tool existed and wanted to find it before going back to that method.


mark2atsafe
Safer
Forum|alt.badge.img+59
  • Safer
  • March 14, 2016

I would use a FeatureMerger as Takashi suggested in his comment. Variables are OK in their place, but can be tough to handle. The FeatureMerger is a better solution I think. Then just set the number of cloned features to the attribute just merged in.