Skip to main content

Hello, I have a table like this:

ID - value x - value y

1 - 5 - 30

2 - 9 - 40

3 - 8 - 70

4 - 76 - 89

I want to replace the value x of ID 4 by the value x of ID 1. So that my table would be like this:

ID - value x - value y

1 - 5 - 30

2 - 9 - 40

3 - 8- 70

4 - 5 - 89

What transformer should I use ?

You could possibly use the VariableSetter and VariableRetriever. Attached fmwt.

 

 

workbenc


Personally I avoid VariableSetter completely now. It is a very hard Transformer to manage, because the execution order of VariableSetter and VariableRetriever can change depending on how the Workspace is executed which is governed by the workflow optimiser, and this will break the Workspace if run in the wrong order, such that even Safe recommend to avoid using VariableSetter/VariableRetriever in the latest versions of FME. In addition, it doesn't play nice with Partial Runs used when debugging your workspace. VariableSetter doesn't "cache" the value but instead stores the value in volatile memory, such that it no longer has the value stored if you say, execute a partial run up to an including the VariableSetter, and then try to launch the rest of the workflow with a second partial run. You can only run partial runs up to before any the VariableSetter or after the VariableRetriever, but never in between the VariableSetter and the VariableRetriever, which again makes Workflow design hard to test.

 

What instead can be done is to replace the original value(s) with a FeatureJoiner like so below, with Attribute Conflict Resolution set to "Use Right" to update the original row(s) with replacement row values.

 

All FeatureJoiner needs is effectively the "lookup" values table of Original Values ID vs Replacement Values ID. That can be done a number of ways, but in the case asked for this is just extract the Replacement value rows wishing to use with a Tester, and then updating these features with which row ID they will be replacing with an AttributeCreator. The Attributes to be updated are controlled with an AttributeKeeper to limit the replacement lookup table to {ID, X}. This bit of the workflow can be adjusted to suit, but all it is producing is ReplacementValueRowID, RowToUpdateID, ReplacementXValue to be consumed by the FeatureJoiner.

 

capture 

 


Reply