Question

Transpose (rotate) data from rows to columns

  • 23 April 2018
  • 3 replies
  • 28 views

Badge

I'm reading a source file and this is the output.

What I would like to have instead is only one row per Name and then have one column for each number of months (as attribute name) and its RRP (as attribute value).

The columns should be the following:

header/attributes:

Name ; 3-Months-RRP ; 6-Months-RRP ; 9-Months-RRP ; 12-Months-RRP

values:

AR201130 ; 5.82; 11.64 ; 17.46 ; 19.40

Thanks for your help.


3 replies

Userlevel 2
Badge +16

I believe the AttributePivoter transformer should be able to do this.

Userlevel 4
Badge +30

Hi @kat

Did you try to use the custom transformer AttributeTransposer?

Thanks,

Danilo

Userlevel 2
Badge +17

Hi @kat, I often use a combination of BulkAttributeRenamer and Aggregator for this kind of task. The AttributeCreator can alto be used to create a new attribute named "@Value(NumberOfMonths)-Months-RRP" storing the value of "RRP", instead of the BulkAttributeRenamer.

Reply