View the original community article here
Last tested: May 13, 2020
According to Shopify docs, liquid doesn't have a native quarter timeframe, so the general method for dynamic labels won't work. We can do this lovely bit of liquid code to hack it:
FOR QUARTER
dimension: label_quarters_ago {
label: "
{% assign month = \"now\" | date: \"%m\" | plus: 0 %}
{% assign year = \"now\" | date: \"%Y\" %}
{% if month <= 3 %}
{% assign quarter = 1 %}
{% elsif month <= 6 %}
{% assign quarter = 2 %}
{% elsif month <= 9 %}
{% assign quarter = 3 %}
{% else %}
{% assign quarter = 4 %}
{% endif %}
{% if quarter == 4 %}
{% assign year3 = year %}
{% assign quarter3 = 1 %}
{% else %}
{% assign year3 = year | minus: 1 %}
{% assign quarter3 = quarter | plus: 1 %}
{% endif %}
Current: {{ year }}Q{{ quarter }} - 3 quarters ago: {{ year3 }}Q{{ quarter3 }}"
sql: 1 ;;
}
FOR CURRENT MONTHlabel: "{{\"now\" | date: \"%b\" %}}"
This content is subject to limited support.