Hitachi Vantara Pentaho Community Forums
Results 1 to 4 of 4

Thread: How to use the Formula step in the Pentaho data integration transformation

  1. #1
    Join Date
    Aug 2012
    Posts
    4

    Question How to use the Formula step in the Pentaho data integration transformation

    Hi,

    I am trying to write a formual and i am not able to use any of the functions available in that step. Am i missing something here on how to use it.

    I want to use an IF ELSE condition where i have many conditions to check and it should result in a certain output if the condition is not met. it throws syntax errors many times.

    please guide me on how to use this step.

    Thanks,
    Vineela.

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

    Default

    Quote Originally Posted by vineela View Post
    it throws syntax errors many times.
    Since you don't give a formula, nobody can tell, what you are doing wrong.
    Usually, the formula editor and the available documentation are sufficient to work things out.

    Given an input field A you could write:
    Code:
    IF([A]=1;"A is 1";IF([A]=2;"A is 2";"A is not 2 nor 3"))
    So long, and thanks for all the fish.

  3. #3
    Join Date
    Aug 2012
    Posts
    4

    Default

    Hi,

    Thanks for your reply.

    Please find below the code that i have put in. It also truncates the code. Is there any character limit to that.

    please let me know where i have gone wrong with this.

    IF(([CONDITION 1 > 0 && Condition 2 > 0 && Condition 3 > 0 && Condition 4 > 0];"A";IF([CONDITION 1 > 0 && Condition 2 > 0 && Condition 3 > 0];"B";IF([condtion 1 <= 0 && Condition 2 <= 0] && [Condition 3 > 0 && Condition 4 > 0]);"C";IF([Condition 1 <= 0 && Condition 2 > 0 && Condition 3 > 0 && Condition 4 > 0]);"D";IF([Condition 1 <= 0 && Condition 2 <= 0 && Condition 3 <= 0 && Condition 4 <=0];"E";"Fail"))

    Can you please provide the correct syntax for the above query.

    If the first set is implemented the output should be A,
    If the second set conditions are met the output is B,
    If the thrid set conditions are met the output is C,
    If the fourth set conditions are met the output is D,
    If the fifth set conditions are met the output is E,
    finally if all the above do not meet the final output should be "Fail".

    Thanks,
    Vineela.

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

    Default

    There are no logical operators, only logical functions.
    OpenFormula / LibFormula is no programming language, after all.

    Rewrite your formula like this:

    Code:
    IF(AND([F1]>0; AND([F2]>0; AND([F3]>0; [F4]>0))); "Success"; "Failure")
    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.