Liquid - Number format

Hey everyone, nice to meet you all.

I have a measure, which has several ifs, as it follows:

measure: someMeasure{
    label: "Measure"
    type: number
    sql:
      {% if category_parameter._parameter_value == "'parameter1'" %}
        case --SomeParamenter
          when ${metric}="Metric1" then ${measures.metric1}
          when ${metric}="Metric2" then ${measures.metric2}
          ...
        end
      {% elsif category_parameter._parameter_value == "'parameter2'" %}
        case --SomeParameter2
          …
        end

html:
    {% if someMeasure._value == 'Metric1'%}
    <p>{{ rendered_value }}</p>

     ...

The rendered_value returns a number with the format 123,456,789.01, and I need it without any decimals but maintaining the thousand separators. I tried several filters, such as:

{{ value | number_with_delimiter | divided_by: 1 | round: 0 | times: 1 }}

But the code above does not return the number with the commas.

Do you have any ideas? Thanks in advance.

1 4 1,574
4 REPLIES 4

Hey, @urz_martin-1639, you have probably moved past this, but just in case I’m sharing this anyway. 

You can try this:

{{ value | number_with_delimiter | divided_by: 1 | floor | times: 1 }} 

I hope it helps.

This doesnt work for me, the entire number_with_delimeter functionality doesn't work? 

hello,

I want to format number values in K, let's 469,000....how do i format it as 469K using liquid.

Thanks

Hi @Shbhm309 

Please check this link for custom formatting of numeric values in Looker - Link 

The link has ways to format numbers and showing K for thousands, M for Millions and so on.

~Ashish

Top Labels in this Space
Top Solution Authors