• Resolved dwaynne

    (@dwaynne)


    I have an equation as follows:

    (function () {
    if (fieldname2 <= 2000000) return 0;
    if (fieldname2 <= 2250000) return 0.05 * (fieldname2 – 2000000);
    return 0.075 * (fieldname2 – 2250000) + 12500;
    })();

    How would I round the result to nearest dollar while preserving 2 decimal places?

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @dwaynne

    If you want to round the result with two decimal places, you can use the PREC operation:

    PREC(x,y) rounds x number with y decimals.

    So, your equation can be edited as follows:

    PREC((function () {
    if (fieldname2 <= 2000000) return 0;
    if (fieldname2 <= 2250000) return 0.05 * (fieldname2 - 2000000);
    return 0.075 * (fieldname2 - 2250000) + 12500;
    })(), 2);

    Best regards.

    Thread Starter dwaynne

    (@dwaynne)

    Got it! Thanks, @codepeople.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Rounding up results with two decimal places’ is closed to new replies.