2014-01-25

NullAttributeMapper Use Case: Assign Value to Missing Attributes

(FME 2014 build 14234)

From this thread. > Community: Merge and Flag

Assume there are these two tables.
FileA:
NamePostcodeDOB
BobNG1 1AA01/01/1970
SueWP1 1AA01/01/1990
FileB:
NamePostcodeDOB
BobNG1 1AA01/01/1970
JohnSW1 1AA01/01/1980

The question was how to merge the tables; the result table must not contain duplicated person's row, and must have additional columns which indicate existence in the original tables.
Required result table should be:
NamePostcodeDOBFileAFlagFileBFlag
BobNG1 1AA01/01/1970YesYes
SueWP1 1AA01/01/1990YesNo
JohnSW1 1AA01/01/1980NoYes

In the Community, an excellent solution using the FeatureMerger has been provided. If I created a workspace according to the solution, the first step for merging tables would be like this.










Immediately after the tables were merged, every "FileBFlag" of NotMerged features and every "FileAFlag" of Unreferenced features are <missing>, i.e. not exist. To satisfy the requirement, finally those <missing> attributes should have a specific value - "No".
The subject I think of here is how to assign "No" to <missing> attributes after merging.

One possible way is to use an AttributeCreator with conditional value setting. "Attribute Is Missing" operator can be used in the setting.











There is another way in FME 2014. That is to use a NullAttributeMapper in order to assign "No" to <missing> FileAFlag and FileBFlag.










Both of them work fine, I cannot say which way is better. But the NullAttributeMapper parameter setting looks simpler than conditional value settings in the AttributeCreator.
I would use the NullAttributeMapper if I encountered a similar requirement.

-----
It's also possible that adding "FileBFlag" (= "No") to NotMatched output and adding "FileAFlag" (= "No") to Unreferenced output in the FeatureMerger using the "Edit Attribute" tool.
If did so, both the AttributeCreator and the NullAttributeMapper would not be necessary no longer, but the process would become difficult to be visible. It's good or not ...

No comments:

Post a Comment