Report Field Format on the Report (negative amount)

gison
gison Member Posts: 128
Dear all,

I got a requirement from our user.
They like to show the amount while it's negative number as (100) instead of -100

I saw there is a format property on the report field. Is it possible to leverage this property?
anyone got a idea would be thankful.

Comments

  • garak
    garak Member Posts: 3,263
    u need only the absolute value without the sign or instead of the sign the () :?:

    like
    -333 --> 300
    or
    -333 --> (300)

    :?:
    Do you make it right, it works too!
  • gison
    gison Member Posts: 128
    this one
    -333 --> (300)
    333 --> 300

    so i think i cannot use ABS(number) function
  • reijermolenaar
    reijermolenaar Member Posts: 256
    Hi Gison,

    Then you will have to create a function in your report like this:
    PROCEDURE FormatNumber(YourNumber : Integer) : Text[250];
    BEGIN
      IF YourNumber >= 0 THEN
        EXIT(FORMAT(YourNumber))
      ELSE
        EXIT('(' + FORMAT(ABS(YourNumber)) + ')');
    END;
    
    And put in the SourceExpr of you textbox “FormatNumber(YourNumber)”

    Regards,
    Reijer Molenaar
    Object Manager
  • bbrown
    bbrown Member Posts: 3,268
    Hi Gison,

    Then you will have to create a function in your report like this:
    PROCEDURE FormatNumber(YourNumber : Integer) : Text[250];
    BEGIN
      IF YourNumber >= 0 THEN
        EXIT(FORMAT(YourNumber))
      ELSE
        EXIT('(' + FORMAT(ABS(YourNumber)) + ')');
    END;
    
    And put in the SourceExpr of you textbox “FormatNumber(YourNumber)”

    Regards,

    The problem here is that, since they are now text, columns of numbers will not line up properly on the decimal point.
    There are no bugs - only undocumented features.
  • Savatage
    Savatage Member Posts: 7,142
    Did you try Control Panel->Regional & Language Options->Regional Options->Customize->Dill down on Negative Number Format-> Change to (1.1) :-k