We use cookies to make HubSpot's community a better place. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).
Sep 30, 2021 6:30 AM
I've have some data in HubDB that represents a metric measuremnt in mm for example 3174. A calculation then converts it to feet and inches;
{% set metric = (row.gf_kitchen_met_1) %}
{% set imperial = 304.8 %}
{% set calculation = (metric / imperial ) | round (1, 'floor') %}
Original = {{row["gf_kitchen_met_1"]}}<br>
Converted = {{ calculation }}"
The example above correctly shows 3174 converted to 10.4
Is there a way to show the converted number with the correct symbols, i.e. 10'4" ?
Solved! Go to Solution.
Sep 30, 2021 6:41 AM
I figured it out using the 'replace' function 😀 ...
New calculation = {{ calculation|replace('.',''') }}"
Sep 30, 2021 11:31 AM
Well sort of @dennisedson. I've had another look at the above and it's only caluclating the 'ft' not inches. Howver using the below is a lot more accurate...
{% for row in housetype_db %}
<!-- Convert mm to ft & inches -->
{% set inches = (row.gf_kitchen_met_1 / 25.4) %}
{% set feet = (inches / 12)|round(0, 'floor') %}
{% set measurement = (inches % 12)|round(0) %}
<!-- Run calculation -->
{% if measurement >= 12 %}
<p>{{ feet + 1 }}'0"</p>
{% else %}
<p>{{ feet }}'{{ measurement }}"</p>
{% endif %}
{% endfor %}
Sep 30, 2021 6:41 AM
I figured it out using the 'replace' function 😀 ...
New calculation = {{ calculation|replace('.',''') }}"
Sep 30, 2021 9:24 AM
Solved in 11 minutes from initial post to answering yourself. 🏍
![]() | Make sure to subscribe to our YouTube channel where you can find the HubSpot Community Developer Show |