-->

Applying Pivot in Pentaho Kettle

2019-08-14 02:32发布

问题:

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

Any help would be much appreciated ..THANKS in advance

回答1:

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:

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

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

This will give the expected output: