Liquid HTML - Format to 2 decimals

We are using {{value|round:2}} to round decimal points, but we need to add 0s to transform values like “3.0” to “3.00”.

In BigQuery, we can use FORMAT("%.2f", price) which does what we want. Is there a liquid html function that does this? We’d rather use liquid html than having to add that function to all of our dimensions’ sql statements or use the dashboard visualization formatting in the series section.

Solved Solved
0 2 10.8K
1 ACCEPTED SOLUTION

Why don’t you use paramater:

value_format_name: decimal_2

If there is a reason for using Liquid I found this: https://stackoverflow.com/questions/37862167/trailing-zeros-in-jekyll-liquid

{% assign price_split = page.products[0].price | round: 2 | split: "." %}
{% assign integral = price_split[0] %}
{% assign fractional = price_split[1] | append: "00" | truncate: 2, "" %}

Formatted Price: {{ integral }}.{{ fractional }}

View solution in original post

2 REPLIES 2
Top Labels in this Space
Top Solution Authors