# Problems formatting and performing a calculation in a budget template

**URL:** <https://community.hubspot.com/t/problems-formatting-and-performing-a-calculation-in-a-budget-template/136359>\
**Category:** CMS Development\
**Tags:** html\
**Created:** [July 16, 2025, 6:12pm UTC](https://community.hubspot.com/t/problems-formatting-and-performing-a-calculation-in-a-budget-template/136359 "2025-07-16T18:12:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ViniBernardo](https://avatars.discourse-cdn.com/v4/letter/v/a6a055/32.png) [@ViniBernardo](https://community.hubspot.com/u/ViniBernardo)\
**Post date:** [July 16, 2025, 6:12pm UTC](https://community.hubspot.com/t/problems-formatting-and-performing-a-calculation-in-a-budget-template/136359/1 "2025-07-16T18:12:35Z")

</div>

Hello everyone…  
I’m editing a budget template, and the main table needs to perform the following calculation:

 ![ViniBernardo_0-1752689388017.png](https://d2qpr2jzcazej7.cloudfront.net/original/1X/4d76320819d74c45bddd9fa68e6d3d9a82e5e45f.png)

“Assinatura Anual” field: Finds the “Quantity” field of the line items, adds them (if there’s more than one), and multiplies them by 12 (to represent per year);  
“Valor por Assinatura” field: Pulls and adds the “Net Price” field of the line items;  
“Investimento Anual” field: Finds the “Net Price” field of the line items, adds them (if there’s more than one), and multiplies them by 12.

I tried to configure something like the following:

**"\<!-- Tabela de valores --\>**  
**\<div class=“container–content”\>**  
**\<table class=“tabela”\>**  
**\<thead\>**  
**\<tr style=“background-color: #f9b915;”\>**  
**\<th\>Assinaturas Anual\</th\>**  
**\<th\>Valor por Assinatura\</th\>**  
**\<th\>Investimento Mensal\</th\>**  
**\<th\>Investimento Anual\</th\>**  
**\<th\>Setup\</th\>**  
**\</tr\>**  
**\</thead\>**  
**\<tbody\>**  
**{% for item in line\_items %}**  
**\<tr\>**  
**\<td\>{{ item.quantity \* 12 }}\</td\>**

**\<td\>**  
**{% set valor = item.price|float %}**  
**R$ {{ “{:,.2f}”.format(valor)|replace(“,”, “X”)|replace(“.”, “,”)|replace(“X”, “.”) }}**  
**\</td\>**

**\<td\>**  
**{% if item.hs\_post\_tax\_amount %}**  
**{% set mensal = item.hs\_post\_tax\_amount|float %}**  
**R$ {{ “{:,.2f}”.format(mensal)|replace(“,”, “X”)|replace(“.”, “,”)|replace(“X”, “.”) }}**  
**{% else %}**  
**R$ 0,00**  
**{% endif %}**  
**\</td\>**

**\<td\>**  
**{% if item.hs\_post\_tax\_amount %}**  
**{% set anual = (item.hs\_post\_tax\_amount|float \* 12)|round(2) %}**  
**R$ {{ “{:,.2f}”.format(anual)|replace(“,”, “X”)|replace(“.”, “,”)|replace(“X”, “.”) }}**  
**{% else %}**  
**R$ 0,00**  
**{% endif %}**  
**\</td\>**

**\<td\>-\</td\>**  
**\</tr\>**  
**{% endfor %}**  
**\</tbody\>**  
**\</table\>"**

It worked initially, but I can’t get it to format to the Brazilian real (R$). It always ends up with a comma at the beginning, or it ignores a trailing 0 or doesn’t set the value when it goes over a thousand

My guess is that the code is generating the gross value, but I can’t find how to make this adjustment.  
I really need help

---

<div class="post-metadata">

**Author:** ![MichaelMa](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@MichaelMa](https://community.hubspot.com/u/MichaelMa)\
**Post date:** [July 16, 2025, 8:20pm UTC](https://community.hubspot.com/t/problems-formatting-and-performing-a-calculation-in-a-budget-template/136359/2 "2025-07-16T20:20:35Z")

</div>

Instead of doing all the replace filters, have you tried using the format\_currency\_value filter? It supports locales which includes the Brazilian Real

`{{ valor | format_currency_value(locale="pt-BR") }}`

As for your specific issue, you would need to do a bit of debugging. What is the value being pushed into your replace filters? You might need to just output every step to see what is causing the issues.

While Hubl is based off of jinja, I don’t believe it supports the .format function from jinja (in favor of their own custom filters and functions).

---

<div class="post-metadata">

**Author:** ![GiantFocal](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/giantfocal/32/41969_2.png) [@GiantFocal](https://community.hubspot.com/u/GiantFocal)\
**Post date:** [July 17, 2025, 3:12am UTC](https://community.hubspot.com/t/problems-formatting-and-performing-a-calculation-in-a-budget-template/136359/3 "2025-07-17T03:12:10Z")

</div>

Just to add, here is the link to the filter documentation:  
[https://developers.hubspot.com/docs/reference/cms/hubl/filters#format\_currency\_value](https://developers.hubspot.com/docs/reference/cms/hubl/filters#format_currency_value)

---

<div class="post-metadata">

**Author:** ![SCaracand](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/scaracand/32/228533_2.png) [@SCaracand](https://community.hubspot.com/u/SCaracand)\
**Post date:** [October 15, 2026, 12:47pm UTC](https://community.hubspot.com/t/problems-formatting-and-performing-a-calculation-in-a-budget-template/136359/4 "2026-10-15T12:47:16Z")

</div>

This post was flagged by the community and is temporarily hidden.
