简体   繁体   中英

pentaho report designer libFormulaErrorValue

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.

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!

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

I had an error where I used one date type as type "Date" and another as "Date(SQL)" where I used the first parameter with format "Date" to derive the other parameter with format "Date(SQL)" through a formula. Which came back to bite me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM