US and Worldwide: +1 (866) 660-7555
Results 1 to 4 of 4

Thread: Int to String formula expression

  1. #1

    Default Int to String formula expression

    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.
    Code:
    =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.

  2. #2

    Default

    Quote Originally Posted by wtolbert View Post
    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.
    Code:
    =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.


    Hi,

    Create a new Function (Right click-> Add Function)
    Select Commom->Open Formula
    In fuction Name put Any String.
    In Formula put: =IF([SEMIANNUAL1_VALUE]=-1;"N/A";[SEMIANNUAL1_VALUE])
    Ricardo Díaz
    Pentaho Consultant
    Quito - Ecuador

  3. #3

    Default

    Ricardo I have tried this approach but I'm still getting incorrect results with the report displaying "-1" instead of the desired "N/A". I assume it may be because I'm trying to convert an int to a string. When I change the attribute to a "text-field" instead of a "number-field" this expression works fine but the additional rows with numbers need to be formatted to a percentage which will be viewed on the report. A resolution may be just to change the number-field to a text field, have an open formula that manipulates the string then have another expression to format the numbers to a percentage. I thought someone here could explain another way.

  4. #4

    Default

    I think there's no other solutions. If you want to write a String in a field you have to use a text-field/label/message-field.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •