Skip to main content
Solved

How to create a string from several records with same ID in one attribute?

  • July 11, 2017
  • 6 replies
  • 225 views

Forum|alt.badge.img

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

Best answer by erik_jan

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.

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.

6 replies

redgeographics
Celebrity
Forum|alt.badge.img+62

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


takashi
Celebrity
  • July 11, 2017

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


redgeographics
Celebrity
Forum|alt.badge.img+62

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.

 


erik_jan
Contributor
Forum|alt.badge.img+23
  • Contributor
  • Best Answer
  • July 11, 2017

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.


danilo_fme
Celebrity
Forum|alt.badge.img+52
  • Celebrity
  • July 11, 2017

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

Thanksworkspace-list.fmwt


takashi
Celebrity
  • July 11, 2017

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")}" />