Search code examples
pivotpentahokettlepdi

Applying Pivot in Pentaho Kettle


I'm using pentaho kettle 5.2.0 version. I'm trying to do pivots on my source data,here it is the structure of my source

Billingid   sku_id    qty
  1           0        1
  1           0        12
  1           0        6
  1           0        1
  1           0        2
  1           57       2
  1          1430      1
  1          2730      1
  2          3883      2
  2          1456      1
  2          571       9
  2          9801      5
  2          1010      1

And this is what I'm Expecting

billingid   0   57  1430  2730  3883  1456  571  9801  1010
   1                *******sum of qty******
   2

this is the steps which I did in row denormaliser, but unable to get expected output

Any help would be much appreciated ..THANKS in advance


Solution

  • For denormaliser to work, you first have to Sort, and the Group the rows, to have the sum of qty. So the transformation is going to look something like this:

    screenshot of transformation

    Sort on billingid and sku_id, and then sum the qty, group by billingid and sku_id:

    screenshot of group by

    Then in denomaliser you need to list each different sku_id, to make a column pr id.:

    screenshot of denomaliser

    This will give the expected output:

    screenshot of expected output