Hitachi Vantara Pentaho Community Forums
Results 1 to 4 of 4

Thread: Javascript Comparison

  1. #1
    Join Date
    Jul 2009
    Posts
    4

    Default Javascript Comparison

    I hope someone can help me with this....... I just can't work out why it doesn't work.

    See the simple attached transformation. I am comparing the current value with a previous value (which are the same), but the Javascript step never seems to think the values are the same.

    Thanks for any help...
    Tom
    Attached Files Attached Files

  2. #2
    Join Date
    Sep 2007
    Posts
    834

    Default

    You have to add lReference in the variables grid (press Get Variables button)

    For comparing with the previous row you can also use the Analytic Query step.

    mc

  3. #3
    Join Date
    Jul 2009
    Posts
    4

    Default

    Thanks for the response, although I have added lReference to the variables but it hasn't made any difference.

    From the Alert step before the "if" statement I can see that the two values are the same, so I can't understand why it is falling in to the "else" part.
    Does it work for you if you add the variable to the list of variables?

  4. #4
    Join Date
    Feb 2012
    Posts
    4

    Default

    Quote Originally Posted by thomascl View Post
    Thanks for the response, although I have added lReference to the variables but it hasn't made any difference.

    From the Alert step before the "if" statement I can see that the two values are the same, so I can't understand why it is falling in to the "else" part.
    Does it work for you if you add the variable to the list of variables?
    I ran into the same problem.. there is a workaround but according to the documentation "All the values that are coming from the data row are Java objects, so a compare between values with "=", ">", "<" etc. will not work." It's necessary to use the compare methods that are specific to the Java object like:
    1. string.equals(otherString)
    2. string.equalsIgnoreCase(otherString)
    3. parseInt(num)==parseInt(num2)

    documentation link: http://wiki.pentaho.com/display/EAI/...a+Script+Value

    (y)
    Last edited by k01; 12-05-2013 at 04:43 PM.

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.