Google Tag Manager

Forum Discussion

l3nxie101's avatar
l3nxie101
Active Member
9 months ago

Changing currency code to a symbol & title case conversion for multiple words

I'm new here so hi everyone - nice to meet you!

I'm trying to figure out if I'm able to change a currency code to a symbol by using filters or similar. Is that possible? Also, is there a way to capitalize the first letter of each word in a string, rather than just the first word?

Thank you!

  • Dany's avatar
    Dany
    Active Member II

    Hi,
    As for the capitalization, there you go:
    https://www.braze.com/docs/user_guide/personalization_and_dynamic_content/liquid/liquid_use_cases#misc-capitalize-words-string

    For the currency, you can use a liquid that would refer to the attribute/property and convert it via case logic:

    {% assign currency_code = "USD" %}

    {% case currency_code %}
    {% when 'USD' %}
    $
    {% when 'EUR' %}

    {% when 'GBP' %}
    £
    {% else %}
    {{ currency_code }} 
    {% endcase %}

    You can use the currency code as a default fallback.  

    Here you can pick the currency codes:
    https://en.wikipedia.org/wiki/ISO_4217




    • l3nxie101's avatar
      l3nxie101
      Active Member

      Thanks for your help here!  DanyWillis DavidO (video was really great!) - I really appreciate it. My reply has been slow as I've been learning more about liquid. I seem to have got that working, but i'm a little stumped now on how to use the filter 'join' to make sure the currency symbol isn't orphaned from the number. Also, is there a way to put the symbol at the front for some currencies and at the end for others? I've been scouring the guides but I cant seem to figure this out. Thank you in advance. 

      • l3nxie101's avatar
        l3nxie101
        Active Member

        And the liquid would help:

        {% assign CurrencyIsoCode = {{custom_attribute.${CurrencyIsoCode}}}%}

        {% case CurrencyIsoCode %}
        {% when 'EUR' %}

        {% when 'GBP' %}
        £

        {% when 'CZK' %}

        {% when ‘DKK %}
        kr

        {% when ‘SEK %}
        kr
        {% endcase %}

        {{custom_attribute.${Total_Repaid__c} | round | number_with_delimiter}}