Forum Discussion

Del's avatar
Del
Qrew Cadet
3 years ago

Convert number to decimal

Looking to have a field on a form that can accept an entered fraction 1/8,  a percent entered as 25%, Decimal .05 or an integer and have it display as a decimal in any case. Do I create a separate formula field?

------------------------------
Del
------------------------------

4 Replies

  • PaulPeterson1's avatar
    PaulPeterson1
    Qrew Assistant Captain
    Here's the happy case where you don't have multiple slashes, a % at the beginning of the text or a combination of slashes and percent signs:

    var number loc = Find([Number Text], "/");

    If(Right([Number Text],1) = "%",ToNumber([Number Text]) / 100,
    $loc > 0, (ToNumber(Left([Number Text], $loc - 1))) / (ToNumber(Right([Number Text], "/"))),
    ToNumber([Number Text]))

    ------------------------------
    Paul Peterson
    ------------------------------
    • Del's avatar
      Del
      Qrew Cadet
      This would be a formula text field?

      ------------------------------
      Del
      ------------------------------
      • PaulPeterson1's avatar
        PaulPeterson1
        Qrew Assistant Captain
        Since you want a numeric value, it would be a formula number field

        ------------------------------
        Paul Peterson
        ------------------------------