Is it possible to find how many rows share the same date?
I've craeted a simple if condition that displays true or false if the date is the month of July. What I now want to do is see how many rows are July, displayed as a number. Is this possible?
{% set test = hubdb_table_rows(1234567, "&plot_status__in=Completed&forecast_year__in=20/21") %}
{% for row in test %}
{% set date = row.legal_completion|datetimeformat('%B') %}
{% if row["legal_completion"] | datetimeformat('%B') == "July" %}
true<br>
{% else %}
false<br>
{% endif %}
{% endfor %}
You could loop through the items and update the values of a field. So you could setup your code like:
{% set test = hubdb_table_rows(1234567, "&plot_status__in=Completed&forecast_year__in=20/21") %}
{% set items_jul = {'amount' : 0 }%}
{% for row in test %}
{% set date = row.legal_completion|datetimeformat('%B') %}
{% if row["legal_completion"] | datetimeformat('%B') == "July" %}
{% do items_jul.update({'amount' : items_jul.amount + 1}) %}
{% endif %}
{% endfor %}
Items in July: {{ items_jul.amount }}
You can. Just replace your if statement with a range from:
if row["legal_completion"] | datetimeformat('%B') == "July"
To
{% if from <= cur && cur <= till %}
So your code will look something like this:
{% set test = hubdb_table_rows(1234567, "&plot_status__in=Completed&forecast_year__in=20/21") %}
{% set items = {'amount' : 0 }%}
{% for row in test %}
{% set cur = row["legal_completion"]|datetimeformat('%Y%m%d') %}
{% set from = module.from_date|datetimeformat('%Y%m%d') %}
{% set till = module.till_date|datetimeformat('%Y%m%d') %}
{% if from <= cur && cur <= till %}
{% do items.update({'amount' : items.amount + 1}) %}
{% endif %}
{% endfor %}
Items in range: {{ items.amount }}
You can. Just replace your if statement with a range from:
if row["legal_completion"] | datetimeformat('%B') == "July"
To
{% if from <= cur && cur <= till %}
So your code will look something like this:
{% set test = hubdb_table_rows(1234567, "&plot_status__in=Completed&forecast_year__in=20/21") %}
{% set items = {'amount' : 0 }%}
{% for row in test %}
{% set cur = row["legal_completion"]|datetimeformat('%Y%m%d') %}
{% set from = module.from_date|datetimeformat('%Y%m%d') %}
{% set till = module.till_date|datetimeformat('%Y%m%d') %}
{% if from <= cur && cur <= till %}
{% do items.update({'amount' : items.amount + 1}) %}
{% endif %}
{% endfor %}
Items in range: {{ items.amount }}
You could loop through the items and update the values of a field. So you could setup your code like:
{% set test = hubdb_table_rows(1234567, "&plot_status__in=Completed&forecast_year__in=20/21") %}
{% set items_jul = {'amount' : 0 }%}
{% for row in test %}
{% set date = row.legal_completion|datetimeformat('%B') %}
{% if row["legal_completion"] | datetimeformat('%B') == "July" %}
{% do items_jul.update({'amount' : items_jul.amount + 1}) %}
{% endif %}
{% endfor %}
Items in July: {{ items_jul.amount }}