Hitachi Vantara Pentaho Community Forums
Results 1 to 3 of 3

Thread: adding a column value for every row till it reaches a condition

  1. #1

    Default adding a column value for every row till it reaches a condition

    Hi

    I have a weird requirement. I need to add a column value for each row till it reaches a particular total.

    For example I have a stream like

    A | B
    -------
    a | 13
    b | 11
    c | 10
    d | 8
    e | 1
    f | 1

    I need something like below.

    A | B | sub_total
    ----------------------
    a | 13 | 13 ( r1 + r 0)
    b | 11 | 24 ( r1 + r2 )
    c | 10 | 34 ( r1 + r2 + r3)
    d | 8 | 42 ....
    e | 1 | 43 ...
    f | 1 | 44 ...


    anyway to get this?

    The purpose of this is, I dont want any rows after a particular sub_total values. For example discard all rows if sub_total > 40


    greatly appreciate any help..!

    thanks
    manoj

  2. #2
    Join Date
    Sep 2009
    Posts
    810

    Default

    Hi there,

    I attached a sample that calculates the total as the rows are passing by...

    Cheers

    Slawo
    Attached Files Attached Files

  3. #3

    Default

    wow..is that this simple!

    Thank you so much Slawo. Very much appreciated.

    Even I thought about this solution but I wrongly assumed that we could not change a value of an incoming field in the stream.

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.