Skip to main content
April 24, 2024
Question

How to remove minus(-) before the number from the below code?

  • April 24, 2024
  • 6 replies
  • 0 views

Code

-------------------------

a!localVariables(
local!currencyValue: a!currency(
isoCode:"USD",
value:-152552.774,
format:"SYMBOL",
decimalPlaces:2,
indicatorAlignment: "START"
),
stripwith(
local!currencyValue,
"$"
)
)

Output

--------------------------

"(152,552.77)"

I need the output as "152,552.77".Can some one help to rectify the code

    6 replies

    April 24, 2024

    Hi [mention:ffba947918f44b98ae5abe7badb7e8fc:e9ed411860ed4f2ba0265705b8793d05] kindly please use this code.

     
    a!localVariables(
    local!currencyValue: a!currency(
    isoCode:"USD",
    value:-152552.774,
    format:"SYMBOL",
    decimalPlaces:2,
    indicatorAlignment: "START"
    ),
    local!data:stripwith(
    local!currencyValue,
    "$"
    ),
    local!data1:split(local!data,")")
    ,local!data2:split(local!data1,"("),
    local!data2[2]
    )

    konduruc733182
    April 24, 2024

    a!localVariables(
      local!currencyValue: a!currency(
        isoCode:"USD",
        value:-152552.774,
        format:"SYMBOL",
        decimalPlaces:2,
        indicatorAlignment: "START"
      ),
      stripwith(
        stripwith(
          local!currencyValue,
          "$"
        ),
        "()"
      )
    )

    Additional strip with would work fine on the output.

    Have you tried fixed function instead?

    stripwith(
      fixed(
        "-152552.774",
        2
      ),
      "-"
    )

    karumurua531442
    April 24, 2024

    hi [mention:ffba947918f44b98ae5abe7badb7e8fc:e9ed411860ed4f2ba0265705b8793d05]  could try this code and let me know is that working fine.

    a!localVariables(
      local!currencyValue: a!currency(
        isoCode:"USD",
        value:-152552.774,
        format:"SYMBOL",
        decimalPlaces:2,
        indicatorAlignment: "START"
      ),
      stripwith(stripwith(
        local!currencyValue,
        "$"
      ),"()")
    )

    stefanhelzle0001
    Brainy
    April 24, 2024

    Why not multiply the value with -1 in case it is negative?

    mikes0011
    Brainy
    April 24, 2024

    If you're looking for the Absolute Value of a number, there's already an Appian function for that:

    docs.appian.com/.../fnc_mathematical_abs.html

    The Expression Guru
    mikes0011
    Brainy
    April 24, 2024
    I need the output as "152,552.77"

    Why are you using a!currency() if you don't actually want the output in currency?

    If you just need the output formatted with commas and a fixed decimal, just use "fixed()".

    As I mentioned before, you can get the absolute value of the input number using "abs()".

    fixed( abs(-152552.774), 2, false() )

    As I always say - the Functions Doc Page is your friend!!  Keep it open in a browser tab!

    The Expression Guru