Question

Display months as words instead of numbers

  • 4 August 2022
  • 2 replies
  • 27 views

I am currently trying to display Months in a word format instead of a number format for a tile. 

Above is what it looks like right now and I want it to say JAN-DEC instead.

This is what the table calculation is:

This is what the entire tile looks like data wise: 

Below is the Reporting Date Month custom dimension”

 


2 replies

Userlevel 1

I created a constant in a manifest file for this scenario (which you then just @ the constant value in the html like     html: @{standard_date_format} ;;) - you could also just update the html directly

constant: standard_date_format {
value: "
{% if _field._name contains 'month' %}
{{ rendered_value | append: '-01' | date: '%b %Y' }}
{% else %}
{{ rendered_value }}
{% endif %}
"
}

 

Userlevel 7
Badge +1

Unfortunately, there’s no easy way to work with lists or array. You would have to create a cascaded IF statement that returns the name of the Month based on a number.. something along these lines:

if(${month_num} = 1, "January",
if(${month_num} = 2, "February",
...

and you’d have to do it on both sides of the string

Reply