0
votes

I have a formula that takes value from query data

Now, I want to skip the formula if the query data is 0

Example: [value1]-[value2]/[value1]*100

If the [value1] is 0, skip the formula.

2

2 Answers

0
votes

First of all, Pentaho Report Designer have build-in Formula Editor, which can greatly simplify your life when constructing these formulas. Not sure starting which version it available, but in 3.6.1 it's for sure.

Also in Pentaho Wiki you may find a useful page describing Formula Expressions: http://wiki.pentaho.com/display/Reporting/Formula+Expressions

As for your particular issue, I think this formula should work:

=IF([value1] = 0; ""; [value1]-[value2]/[value1]*100)

Starting equal sign is required in each formula!

0
votes

By observing your formula, [value1] field is there in the denominator, there might be a chance to get zero(0) for that field. This is logical error. If you handle that one, you can overcome this error.

For your case this formula would work.

= ( [value1]-[value2]/ IF(OR(ISEMPTYDATA([value1]); [value1] = 0)  ;1;[value1]) )*100