Added by Jens Bleuel, last edited by Jens Bleuel on Nov 17, 2011  (view change)

Labels:

Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.

Description

The Formula step can calculate Formula Expressions within a data stream. It can be used to create simple calculations like [A]+[B] or more complex business logic with a lot of nested if / then logic.


When you press on the Formula cell entry, the formula editor window opens and gives you help on the available functions:


The formula editor window does a direct check on the syntax and the field names supplied. In case of an error you get the error message direct, for instance:

The page http://wiki.pentaho.com/display/Reporting/Formula+Expressions says the formula's are not for PDI!

Comment: Posted by A L at Oct 15, 2010 09:10

*** Don't get Burned ***

Excerpt from the PDI Forum from Tony...

The functions in the formula step don't act like functions in java/javascript/etc. - and you can't assume that functions return -1 codes on failure. So sometimes you have to use the "Informational" functions to evaluate the results.

In your case you can use this modified version to get what you want:

IF(ISERR(FIND("z";"abcabc")); "POOP";"NOT POOP")

Here the ISERR function checks for an error from the FIND function evaluation and converts it into a boolean result for evaluation in the IF statement.

Don't expect this to act like Javascript. It is a different animal...

Comment: Posted by Kent Andrews at Nov 18, 2010 10:18

@A L:

> The page [http://wiki.pentaho.com/display/Reporting/Formula+Expressions|display/Reporting/Formula+Expressions] says the formula's are not for PDI!

It only states, that you must not start the formula with a "=", that's the difference.

Comment: Posted by Jens Bleuel at Nov 17, 2011 06:41

@Kent: Thanks for the sample, it is similar to the sample_find.ktr attached to http://jira.pentaho.com/browse/PDI-1241 (using the ISERROR instead the ISERR)

Comment: Posted by Jens Bleuel at Nov 17, 2011 06:43