Discussions

 View Only
  • 1.  Convert number to decimal

    Posted 11-29-2021 17:30
    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
    ------------------------------


  • 2.  RE: Convert number to decimal

    Posted 11-29-2021 18:17
    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
    ------------------------------



  • 3.  RE: Convert number to decimal

    Posted 11-29-2021 18:19
    This would be a formula text field?

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



  • 4.  RE: Convert number to decimal

    Posted 11-29-2021 18:30
    Since you want a numeric value, it would be a formula number field

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



  • 5.  RE: Convert number to decimal

    Posted 11-29-2021 18:32
    Thanks, some modifications but works!

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