Question

Create attribute columns based on attribute row values

  • 19 February 2014
  • 3 replies
  • 34 views

I have this type of data set with a number of observations with values of town, type and number - and a possibility of observing more of the same type in the same town.

 

 

Town; Type; Number

 

Town 1; Type A; 4

 

Town 1; Type A; 2

 

Town 1; Type B; 6

 

Town 2; Type A; 7

 

Town 2; Type B; 11

 

Town 3; Type C; 21

 

Town 3; Type A; 32

 

Town 3; Type B; 3

 

Town 3; Type B; 4

 

 

etc.

 

 

How would I get my source data set to look like this? Town; Type A; Type B; Type C; Sum Town 1; 6; 6; 0; 12

 

Town 2; 7; 11; 21; 39

 

Town 3; 32; 7; 0; 39

 

 

I have tried using the new AttributePivot on Town and Type, but it would give me this result really.

 

 


3 replies

Userlevel 2
Badge +17
Hi,

 

 

The BulkAttributeRenamer can be used effectively.

 

1) BulkAttributeRenamer

 

Rename: Selected Attributes

 

Seleted Attributes: Number

 

Action: Regular Expression Replace

 

Text To Fine: .*

 

String: Type  (Attribute Value)

 

 

2) AttributeExposer

 

Attributes to Expose: Type A, Type B, Type C

 

 

3) Aggregator

 

Group By: Town

 

Mode: Attributes Only

 

Keep Input Attributes: No

 

Attributes to Sum: Type A, Type B, Type C

 

 

4) AttributeCreator

 

Sum = @Value(Type A)+@Value(Type B)+@Value(Type c)

 

 

Takashi
Userlevel 2
Badge +17
I found that attribute value can be specified as new attribute name in the AttributeCreator of FME 2014. If you are using FME 2014, can use the new functionality.

 

 

1) AttributeCreator

 

@Value(Type) = Number  (Set value of "Type" to new attribute name)

 

Sum = Number

 

 

2) AttributeExposer

 

Attributes to Expose: Type A, Type B, Type C

 

 

3) Aggregator

 

Group By: Town

 

Mode: Attributes Only

 

Keep Input Attributes: No

 

Attributes to Sum: Sum, Type A, Type B, Type C
Userlevel 2
Badge +17
Sorry, that's not new. FME 2012, 2013 also can do that. You can type "@Value(Type)" directly in Attribute Name column of the AttributeCreator.

Reply