Format number to 2 DPs

I have some data that I'm importing and I want to convert to currency format nnn.nn - there doesn't appear to be a way to do this in aperture. Any ideas? I've tried the Round function but no joy - I want to convert 28 to 28.00 etc.

Best Answer

  • Henry SimmsHenry Simms Administrator
    Accepted Answer

    @SpeedySteven I noticed that the re-usable formula was exported from a Data Studio 2.4.2 environment. These packages are typically not backwards-compatible, so if you have an earlier version of Data Studio you will probably find that you can't import. Any version 2.4.2 or later should be fine.

Answers

  • Henry SimmsHenry Simms Administrator
    edited September 2
    Hi @SpeedySteven , there's a good discussion about this problem here: https://community.experianaperture.io/discussion/668/transform-to-decimal

    The last proposed solution in the thread is probably the most complete.
  • SpeedyStevenSpeedySteven Super Learner

    Thanks Henry - that's really helped - I can't seem to save the re-usable formula though

  • SpeedyStevenSpeedySteven Super Learner

    Thanks Henry - we need to upgrade

  • @SpeedySteven This function ought to do what you want, without any need to upgrade anything.

    How it works ...

    This function takes an input parameter (called inNumber

    Multiply inNumber by 100 and round it to zero decimal places (using Half-Even rounding)

    Save the rounded number as a variable "RoundNum"

    We're then going to chop this number up into 2 bits - the right two digits (let's call that RightBit) and everything else (LeftBit).

    We then concatenate these two bits either side of a decimal point and save it in the variable outString : LeftBit.RightBit

    This works for any number except zero, which ends up as ".0", so we have to handle zeroes as a special case, so we check to see if the outString = ".0" and if it does we return "0.00", if not we return outString

    Test Data


  • @SpeedySteven Here's a function that does what you want without needing to upgrade anything.

    How it Works

    This function takes an input parameter (called inNumber

    Multiply inNumber by 100 and round it to zero decimal places (using Half-Even rounding)

    Save the rounded number as a variable RoundNum

    We're then going to chop this number up into 2 bits - the right two digits (let's call that RightBit) and everything else (LeftBit).

    We then concatenate these two bits either side of a decimal point and save it in the variable outString = LeftBit.RightBit

    This works for any number except zero, which ends up as ".0", so we have to handle zeroes as a special case, so we check to see if the outString = ".0" and if it does we return "0.00", if not we return outString

    Test Data


  • @SpeedySteven This function does what you want without needing to upgrade anything.

    How it Works

    This function takes an input parameter (called inNumber

    Multiply inNumber by 100 and round it to zero decimal places (using Half-Even rounding)

    Save the rounded number as a variable RoundNum

    We're then going to chop this number up into 2 bits - the right two digits (let's call that RightBit) and everything else (LeftBit).

    We then concatenate these two bits either side of a decimal point and save it in the variable outString (LeftBit.RightBit)

    This works for any number except zero, which ends up as ".0", so we have to handle zeroes as a special case

    So we check to see if the outString = ".0" and if it does we return "0.00", if not we return outString

    Test Data


Sign In or Register to comment.