Skip to main content

Hi,

I need to denormalize rows into repetitive numbered columns. Here's an example.

Here is the normal version as it is in the relational db. Note that the three rows all have the same value in ID_DETAIL field.

image.pngHere is the desired result. Note that for this one DETAIL, we end up with three groups of columns (ID_MENTION, MENTION, PRECISION).

Denormalized with multiple repetitive columnsHow would one do this in FME ?

The number of repetitive groups of columns would be defined by the detail in the dataset having the most mentions (in my example it was 3).

I was thinking of some kind of grouping on ID_DETAIL and some kind of "for-each-loop". But any better suggestion appreciated !

Hello @timotheebecker​ 

I would suggest using a Counter to number for each row of a repetitive group and then renaming the attributes based on the resulting number using a BulkAttributeRenamer. Then use an Aggregator to aggregate features with the same ID_DETAIL value into one features. Note that you will need to expose the renamed attributes (eg. ID_MENTION_1, MENTION_1, etc.) using an AttributeExposer.

I have attached a workspace demonstrating this approach.


An alternative approach: Build a list (ListBuilder, group by ID_DETAIL), then use ListBreaker (from FME Hub), start numbering at 1. Next use the AttributeExposer.

Denormalize_Rows 

 


Hello @timotheebecker​ 

I would suggest using a Counter to number for each row of a repetitive group and then renaming the attributes based on the resulting number using a BulkAttributeRenamer. Then use an Aggregator to aggregate features with the same ID_DETAIL value into one features. Note that you will need to expose the renamed attributes (eg. ID_MENTION_1, MENTION_1, etc.) using an AttributeExposer.

I have attached a workspace demonstrating this approach.

Thanks Debbiatsafe. That works fine!


An alternative approach: Build a list (ListBuilder, group by ID_DETAIL), then use ListBreaker (from FME Hub), start numbering at 1. Next use the AttributeExposer.

Denormalize_Rows 

 

Hello,

I haven't tried your approach geomancer but it looks very elegant. I'll try it soon.


Reply