Skip to main content
Solved

Group same values in different features and attributes by id

  • September 11, 2024
  • 2 replies
  • 209 views

kongadrummer
Participant
Forum|alt.badge.img+3

Hello everyone,

I have the following data structure and I don’t know which solution would be the best in FME Form to get the required result:

attribute1; attribute2; attribute3
Kreuzberg; Rom; group 1
Berlin; Kreuzberg; group 1
England; London; group 4
London; England; group 4
Lissabon; Carrer; group 2
Carrer; Lissabon; group 1
Kreuzberg1; Rom; group 1
Rom; Kreuzberg2; group 1

I need to create a group_id attribute that has the same id where attribute1 values reappear in attribute 2 and vice versa + the features need to have the same attribute3 to get the same group_id. This is how the output should look like:

attribute1; attribute2; attribute3;group_id
Kreuzberg; Rom; group 1;1
Berlin; Kreuzberg; group 1;1
England; London; group 4;2
London; England; group 4;2
Lissabon; Carrer; group 2;3
Carrer; Lissabon; group 1;4
Kreuzberg1; Rom; group 1;5
Rom; Kreuzberg2; group 1;5

Thanks for helping!

Best answer by kongadrummer

Thank you this was such a big help! Thank you also for all the details :) 

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.

2 replies

bwn
Evangelist
Forum|alt.badge.img+26
  • Evangelist
  • September 11, 2024

Something like Matcher possibly easiest, but can also see a FeatureJoiner + Tester solution alternative

Matcher though will put the group_id straight onto the output.  It just needs attribute1 and attribute2 to be named temporarily as a common attribute name.  Counter also here to give each row a unique Row ID, so that Matcher will not match the same row to itself in the Attributes That Must Differ parameter.

 

Now, the rules you’ve stated give a slightly different result.  Technically Rows 3 and 4 match twice in two separate groups,  They have a match first on England → England,  and a separate match on London → London and so Matcher, according the match rules, finds these rows belong to two groups, an England Group, and a London Group.   These can be filtered out if needed, but left as is.

Similarly, technically Rows 1, 7 and 8 also all belong to 1 Group, being the “Rom” Group rather than what you’ve got with only Rows 7, 8 in the Group.

Also the option of outputting the groups into Lists on the Matcher SingleMatched Port is also enabled to have options for handling the data this way through List operations.

 

Tidy up is a little more work to include and handle the NotMatched Features and give them a unique group_id but is something like this


 

 


kongadrummer
Participant
Forum|alt.badge.img+3
  • Author
  • Participant
  • Best Answer
  • September 13, 2024

Thank you this was such a big help! Thank you also for all the details :)