Decimals as currency

Options

Are there any ways to get a decimal/number formatted into a currency/dollar? I have a case where a column is being calculated and rounded as a decimal to the hundredths (2 decimal places), but if the amount ends up as a whole number (5.00) or ends with a zero (5.50), it drops off the zero(s) in the decimal. Anyone have a way to ensure the zeros dont drop? Also currently using "Tables: Apply formulas to column" as the action.

Best Answer

  • Sean_510793
    Sean_510793 Posts: 69 admin
    edited January 2022 Answer ✓
    Options

    I just found this question and wanted to chime in. The answer that Jeff_146001 presented would work as a Field Formula, but NOT in the context that Carli_126179 presented as part of a "Tables: Apply formulas to column" Action. That said, I'd like to offer up a more canonical way of formatting currency that would also support international currency and numerical formatting.

    In a Field Formula, it would be:

    result = fields["number-to-use"].toLocaleString("en-US", {style: "currency",  currency: "USD"});
    

    or you can also directly insert the field (i.e.):

    result = {{number-to-use}}.toLocaleString("en-US", {style: "currency",  currency: "USD"});
    

    I haven't tested the Apply formulas but believe it would be:

    columns("field-to-insert-into") = columns("number-to-use").toLocaleString("en-US", {style: "currency",  currency: "USD"});
    

Answers