Rounding numbers | Community
Skip to main content
Christin_Scholz
Level 2
Dec 2, 2019 2:53 PM UTC
Solved

Rounding numbers

Hi all,

how can I format a number in lead database like 58.5123434565 into 58,51 within the email?

I want to use it as currency in emails with comma (german way of writing).

I tried with the script token, but apparently it didn't work.

$math.roundTo( x, y )

Can you guys please help me on that? (I'm not a developer )

Best
Christin

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
Dec 2, 2019 8:23 PM UTC

You didn't specify banker's rounding or arithmetic rounding.

 

Either way you need a locale-specific format for Germany (de_DE).

 

Banker's rounding is the default mode (note this not a Marketo-specific thing, nor a Velocity thing, but across anything built on the Java foundation):

 

#set( $customFormat = $number.getNumberFormat("${esc.h}${esc.h},${esc.h}${esc.h}${esc.h}.00", $convert.toLocale("de_DE") ) ) banker's: ${customFormat.format($lead.SomeField)}‍‍‍‍‍‍

 

 

If you need arithmetic rounding (if neither you nor your manager is a developer or accountant, you probably meant arithmetic):

 

#set( $customFormat = $number.getNumberFormat("${esc.h}${esc.h},${esc.h}${esc.h}${esc.h}.00", $convert.toLocale("de_DE") ) ) #set( $void = $customFormat.setRoundingMode($field.in($customFormat.getRoundingMode()).HALF_UP) ) arithmetic: ${customFormat.format($lead.SomeField)}‍‍‍‍‍‍‍‍‍

 

 

Update 2019-12-07: please read responses to your threads, it's very frustrating to take time to provide Correct answers and have the thread abandoned.

6 replies

SanfordWhiteman
Level 10
Dec 5, 2019 3:06 PM UTC

 please return to your thread. The correct answer was given within hours of your post.

Translate
Christin_Scholz
Level 2
Dec 9, 2019 8:16 AM UTC

I'm sorry, I was sick.

Thank you very much for your answer!

Translate
SanfordWhiteman
Level 10
Dec 11, 2019 3:38 AM UTC

Thanks for checking back, I appreciate it.

Translate
SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
Dec 2, 2019 8:23 PM UTC

You didn't specify banker's rounding or arithmetic rounding.

 

Either way you need a locale-specific format for Germany (de_DE).

 

Banker's rounding is the default mode (note this not a Marketo-specific thing, nor a Velocity thing, but across anything built on the Java foundation):

 

#set( $customFormat = $number.getNumberFormat("${esc.h}${esc.h},${esc.h}${esc.h}${esc.h}.00", $convert.toLocale("de_DE") ) ) banker's: ${customFormat.format($lead.SomeField)}‍‍‍‍‍‍

 

 

If you need arithmetic rounding (if neither you nor your manager is a developer or accountant, you probably meant arithmetic):

 

#set( $customFormat = $number.getNumberFormat("${esc.h}${esc.h},${esc.h}${esc.h}${esc.h}.00", $convert.toLocale("de_DE") ) ) #set( $void = $customFormat.setRoundingMode($field.in($customFormat.getRoundingMode()).HALF_UP) ) arithmetic: ${customFormat.format($lead.SomeField)}‍‍‍‍‍‍‍‍‍

 

 

Update 2019-12-07: please read responses to your threads, it's very frustrating to take time to provide Correct answers and have the thread abandoned.

Translate