Skip to main content
Question

Create attribute columns based on attribute row values

  • February 19, 2014
  • 3 replies
  • 206 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.

 

 

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.

3 replies

takashi
Celebrity
  • February 19, 2014
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

takashi
Celebrity
  • February 21, 2014
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

takashi
Celebrity
  • February 21, 2014
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.