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)?


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.

View original
Did this help you find an answer to your question?

4 replies

takashi
Evangelist
  • 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
Evangelist
  • March 13, 2016
takashi wrote:

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+51
  • 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.


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