Hitachi Vantara Pentaho Community Forums
Results 1 to 6 of 6

Thread: Alternative to using the IF expresion within a formula step

  1. #1

    Default Alternative to using the IF expresion within a formula step

    Be used to SQL CASE expressions, I do not find the IF very easy to use. The following expression:

    [XTYPE]/(IF([YPUB]=0;1;[YPUB]))

    generates :

    "ERROR : Parse Exception : Parsing error in formula : null "

    for whatever reason.

    Is there an alternative? I have seen an item on adding CASE to Kettle version 5, but have no idea whether this will be in the next release..

  2. #2
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    A Java Expression can do the same for you, but you can easily avoid the error by not using parentheses around the IF()
    Code:
    [XTYPE] / IF([YPUB]=0;1;[YPUB])
    So long, and thanks for all the fish.

  3. #3

    Default

    Thank you.. I wrote some code in the past 20 years, but never had problems with additional parentheses. Typical Kettle behavior?

  4. #4
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    Kettle puts a load of jars to good use, one particular jar being libformula-1.2.8.jar borrowed from Thomas Morgner of JFreeReport fame (now with Pentaho, watch out for user Taqua in forum Pentaho Reporting). Blame him, if the formula parser trips over your excessive use of parentheses
    So long, and thanks for all the fish.

  5. #5

    Default

    Brilliant; another lesson learned. Pity that Pentaho forums do not allow for giving out stars, otherwise you would have received one..

  6. #6
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    So long, and thanks for all the fish.

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.