Hitachi Vantara Pentaho Community Forums
Results 1 to 3 of 3

Thread: rollup/aggregate fn in PDI

  1. #1

    Default rollup/aggregate fn in PDI

    Hi,....

    I am kind of replicating the aggregate/rollup functionality in pentaho

    For the i/p data ....

    Need to assign a temp var and for every row . Based on some column cdns

    example: if ( type== "D" && value == "2") -- (these are i/p columns)

    I need to increment the temp var to 1 else 0. (Need to get total count)

    This should be processed for each row ..

    Q ) Is there any step which can do this ??

    Q) If not , I suppose I may have to work with MJS. I am new to Java scripting..

    --- q) How can I loop through each row for the comple file ?

    --- q) And with in the loop How can i check these cdns and increment the temp var..

    Thanks in advance !!!

  2. #2

    Default

    I am not sure if i am correct in my below code ..... But I am not getting the expected results




    var temp="0";

    for (var i=0;i<getInputRowMeta().size();i++) { //loop through the actual row

    temp;
    {
    if (FieldString2="D" && FieldString3="2")
    temp=temp+1
    else
    temp=temp;
    }
    }

    Sorry kind of new to Java


    Any help would be appreciated !!!!

  3. #3
    Join Date
    Apr 2008
    Posts
    4,696

    Default

    Remember that for most things, it is easiest to think of data as independent movement through the Transform. It doesn't interact with other data as it goes through the pipe.

    Some major exceptions to this:
    * Sort (makes all rows get into a specified order)
    * Blocking (wait until the last one gets here, before the first one is allowed to leave)
    * Group By (Pull Similar data together)

    What you want to do is:
    * Sort incoming data (I/P ?) on Type and Value
    * Group By ... Type and Value... And add aggregate fields "OccurCount" as Type "Number of Values (N)"

    This will give you output like:

    Type | Value | OccurCount
    A | 1 | 1
    B | 2 | 1
    D | 2 | 3
    D | 3 | 2
    ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.