3 Replies Latest reply: Jun 16, 2014 10:37 AM by Riccardo Malaspina RSS

    Transpose rows to cols

      Hi all,

       

      I'm looking for a solution where I need to transpose a table from rows to columns. The example below works as intended, but I have about 400 ProdID's, any suggestions how to solve this in a smart way?

       

      Thanks,

      Jonas

       

      OrgData:

      load  *Inline

      [Knumber, ProdID, Value

      1,6,1000

      2,7,2000

      3,8,3000

      4,9,4000

      5,10,5000

      ];

       

      RowsToCols:

      LOAD Knumber,

                 ProdID AS Prod1,

                 Value

      RESIDENT OrgData

      WHERE ProdID = '6';

       

      CONCATENATE LOAD Knumber,

                 ProdID AS Prod2,

                 Value

      RESIDENT OrgData

      WHERE ProdID = '7';

       

      CONCATENATE LOAD Knumber,

                 ProdID AS Prod2,

                 Value

      RESIDENT OrgData

      WHERE ProdID = '8';

       

      // ProdID = 9, 10 e.t.c ...

       

      DROP TABLE OrgData;