Question

I'm attempting to write a formula expression in Pentaho Report Designer 3.9. The expression will take the SEMIANNUAL1_VALUE attribute which is an int or number-field and display "N/A" when the value is -1. Below is the expression I currently have that is not working.

=IF([SEMIANNUAL1_VALUE] = -1 ; TEXT("N/A"); [SEMIANNUAL1_VALUE] )

I have this expression in the "value field" in Pentaho Report Designer which should handle this exception. Your help is appreciated.

Was it helpful?

Solution

You have the solution wrong. You can't have code that in one hand returns a string, on the other returns a number. Thats never sensible! Think in the case where you wanted to use this field in further expressions later on etc - not just the case of displaying the field on the report.

The solution is simply to return NA() rather than TEXT("N/A") Which will return null. Then set the ifnull flag on the numeric field to be "N/A". That works. Because ifnull is just the display property of the field this works fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top