Skip to main content


Hi,



I have two non-spatial
features and need to bring together the string values from several records in
one attribute.


For
example:



FK1


IDState1CH2US3AU4IT5FR



FK2


IDNarrative1B11B21B32C12C23D33D43D53D7



I need to
get follow result:

IDStateNarrative1CHB1, B2,
B32USC1, C23AUD3, D4,
D5, D7



How can I
do it with FME?



Thanks for
help

Use a ListBuilder on the 2nd dataset, set to group by ID, and then a ListConcatenator on the Narrative attribute. Then a FeatureMerger to match it with the 1st dataset


Hi @zoran68, the FeatureMerger with "Generate List" option can be used to merge multiple FK2 records as list elements to a FK1 record having the same ID. You can then use the ListConcatenator to concatenate the list elements using any delimiter (e.g. comma).


Use a ListBuilder on the 2nd dataset, set to group by ID, and then a ListConcatenator on the Narrative attribute. Then a FeatureMerger to match it with the 1st dataset

Never mind, I messed up my answer and as I was trying to get it right @takashi came up with the right one.

 


You can use an Aggregator (concatenate Narrative and group by ID) on the second dataset and then use a FeatureMerger to merge that dataset to the first.


Hi @zoran68, i created the template file with your case using the FeatureMerger.

Thanksworkspace-list.fmwt


off-topic: I'm exploring more effective usage of XQuery expressions in FME workspaces. This might be a typical example.

0684Q00000ArKagQAF.png

ROOT Template:

let $r := <root>{fme:process-features("SUB")}</root>
return {
    "ID": fme:get-attribute("ID"),
    "State": fme:get-attribute("State"),
    "Narrative": fn:string-join({for $v in $r/sub/@Narrative return $v}, ",")
}

SUB Template:

<sub Narrative="{fme:get-attribute("Narrative")}" />


Reply