Format calculations to 2 fixed decimal places | XM Community
Skip to main content

I am using a survey as an order form. I'm performing math calculations in embedded data fields, multiplying the price per unit by the quantity, then displaying the total using piped text on an order summary. Since the result should be formatted as currency (US dollars), I would like to display the totals with 2 fixed decimal places. I don't see a way to do that, although I was able to round the totals that were calculated with percentages to 2 places.
I don't know javascript, and I'm on a very tight deadline with this project. I have one week before launch. If anyone could give me some help with that, I would be very grateful! I put in a support ticket, but they told me that it is custom development and they can't help. I'm surprised that formatting numbers as currency isn't possible without javascript!

Hi, I know this is late but I believe you'll need to use the round function in the survey flow to calculate returns with decimals. In the examples below, the ", 2" or ", 1" designates the number of decimals. For currency, you'd want ", 2".
ROUNDING
$e{ round( 10 / 3 , 2 ) } rounds 10/3 with 2 decimal places and resolves to 3.33.
or
$e{ round( ( ( gr://SC_ey9XzMvRiDHE4ct/Score / gr://SC_0feLdfz1vM7P4qN/Score ) * 100 ) , 1 ) }


Leave a Reply