Hitachi Vantara Pentaho Community Forums
Results 1 to 2 of 2

Thread: Counting values in rows

  1. #1
    Join Date
    Jul 2010
    Posts
    8

    Default Counting values in rows

    Hi,
    I'm trying to rebuild our cognos transformations into PDI. We have a transformation that uses variables to add a counter depending on some previous rows , and we don't seem to be able to build this in PDI. I will try to use a simple example. Suppose you have 3 rows A,B and C which all are strings. I can compare the actual value with the previous row with the analytic query.

    A B C COUNTER

    1 2 3 1
    2 2 4 1 (reset)
    2 2 5 2 (+1)
    2 3 5 3 (+1)
    2 4 6 4 (+1)
    3 4 6 1 (reset)
    3 5 6 2 (+1)
    3 5 6 2 (stays)
    3 5 6 2 (stays)

    When A is different from the previous rows - the counter resets to 1...
    If A is the same but B or C are different - the counter adds 1
    if A , B and C are the same - the counter stays the same.

    Thanks for looking !
    WaveX

  2. #2
    Join Date
    Oct 2007
    Posts
    107

    Default

    Hi Wavex,

    Since this is very specific logic, you could calculate your counter within javascript by looking at the previous row data. Search within the forum on "Previous Row" and Javascript and you should find a few entries as it has been discussed before.

    Cheers,
    C.

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.