How to format an input amount with format of let say (100) to be read as -100?

I have an input format of either let say -100 or (100) but I want it to be read as -100. Is there way to go around this? Thanks!

  Discussion posts and replies are publicly visible

Parents Reply Children
  • Hi David, I believe Victor is looking to do the opposite (input of "-100" or "(100)", output always "-100"), but yes the text function does save some lines there for the same result, if we apply as below.  However, you may want to be dynamic on the formatting input in case the input is longer than a 3 digit number.  Assuming the desired result is essentially a negative sign concatenated with the abs() value of the input.  

    a!localVariables(
      local!inputs: {100,-100,"(100)",1000},
      
      a!forEach(
        items: local!inputs,
        expression: {
          text(
            abs(fv!item),
            concat("-",makerange(len(abs(fv!item)),"#"))
          )
        }
      )
    )

  • Thank all for the response. We used the logic below to meet our requirement.

    todecimal(
    if(fixed(rounddown(index(local!row, 2, null)),2,true)<>index(local!row, 2, null)
    , todecimal(index(local!row, 2, null))*(-1)
    ,index(local!row, 2, null))
    )