Skip to main content

Hi, and of course “HELP!” 😁

I need to take some values in a column and create column names from them, taking the associated values with them.

My starting table looks like this (note this is in Excel, but the table exists within an FME workflow, I am just showing it like this to make it easier to understand… hopefully!!!!!):
 

 

Asset_ID is my unique identifier. You will see there are either 3 or 4 duplicates of that number.

Column B “CHAR_TYPE_CD” has the values I want to turn into new column headings, combined with the existing column headings in C, D, and E.

This is ultimately what I want it to look like:
 


Note The values from the original Column B are transposed and combined with the previous column names. There are 4 individual attribute values in the original column B, namely:

CM-ELCNT; CM-GRPNG; CM-VOLVL; and CM-VN

Original column C “EFFDT” now becomes “EFFDT CM-ELCNT”

Original column D “CHAR_VAL” now becomes “CHAR_VAL CM-ELCNT”

Original column E “SRCH_CHAR_VAL” now becomes “SRCH_CHAR_VAL CM-ELCNT”.

This process is then repeated for the next value in original column B:

New columns created are EFFDT CM-GRPNG; CHAR_VAL CM-GRPNG; SRCH_CHAR_VAL CM-GRPNG and so on.

Importantly of course the relevant values of original columns A, C, D, and E all go into the newly named columns.

I have added the spreadsheet with 2 sheets in it, so you can see the data.

Any help warmly  appreciated. Thank you in advance.

Stu

UPDATE!
I have created a solution by hard-coding the values, not ideal, but it works. It goes through an AttributeFilter to split-out the values of the CHAR_TYPE_CD column, then into AttributeManagers to rename those columns using those split-out values by hard-coding.
Then all merged back together with Aggregator.

 


If anyone knows a way of automating the renaming those columns rather than hard-coding please let me know.

Stu


You can create an attribute with the name being the value of another attribute.

Try something like that, and then into an aggregator which is set to Merge Attributes the same as you have there already.


You can create an attribute with the name being the value of another attribute.

Try something like that, and then into an aggregator which is set to Merge Attributes the same as you have there already.

Thank you so much, I was trying to work out how to do that but hadn’t got the syntax correct. Is that screenshot from Attribute Manager, or AttributeCreator, or something else? (It’s bentime for me in the UK right now so don’t have my work pc on!😴 )


Thank you so much, I was trying to work out how to do that but hadn’t got the syntax correct. Is that screenshot from Attribute Manager, or AttributeCreator, or something else? 

AttributeCreator, but you can do the same in an AttributeManager as well.

One other thing to note is that because the attribute name is dynamic (from FME’s point of view it could be anything), you have to Expose it if needs to be used in other transformers.


Reply