Skip to main content
Solved

Numeric value in Klaviyo

  • August 20, 2024
  • 1 reply
  • 141 views

Forum|alt.badge.img+1

Hello,

How can I remove the ".0" decimal if the numeric value is a whole number, so it reads "$16" instead of "$16.0"? However, if the numeric value includes decimals, like "$16.29", it should remain as is without rounding or removing the ".29" decimal.

Thank you!
 

 

Best answer by chloe.strange

Hi @Joselito

Thanks for being a part of our community! In django templates, the floatformat filter is used to control the number of decimal places displayed. floatformat will round the number to the specified decimal places, and it will only display decimal places if they are non-zero.

To round a decimal number but display it as an integer if it ends in .00, you would use floatformat with a negative value. For example:

{{ value|floatformat:"-2" }} . This will round the number to two decimal places. However, if the number ends in .00, it will be displayed as an integer without any decimal places. I hope this helps!

~Chloe

View original
Did this topic or the replies in the thread help you find an answer to your question?

1 reply

chloe.strange
Community Manager
Forum|alt.badge.img+41
  • Community Manager
  • 426 replies
  • Answer
  • August 29, 2024

Hi @Joselito

Thanks for being a part of our community! In django templates, the floatformat filter is used to control the number of decimal places displayed. floatformat will round the number to the specified decimal places, and it will only display decimal places if they are non-zero.

To round a decimal number but display it as an integer if it ends in .00, you would use floatformat with a negative value. For example:

{{ value|floatformat:"-2" }} . This will round the number to two decimal places. However, if the number ends in .00, it will be displayed as an integer without any decimal places. I hope this helps!

~Chloe