La fonction de suggestion automatique permet d'affiner rapidement votre recherche en suggérant des correspondances possibles au fur et à mesure de la frappe.
Then I use the number of days and round off to show how many weeks...
{% for row in table %}
Answer = {{ total_weeks }}
{% endfor %}
The above works, but now I want to display a bar graph that shows how many show 4 weeks, 5 weeks, 6 weeks etc. How do I calculate this? I tried the below but it didn't work:
{% set test1 = (total_weeks, "equalto", "4") | length %}
Good spot! You're correct that the loop does need to cover everything as you stated. This works if you want to display all the information inside a table (see below), but what I now need to do is calculate how may rows show 01 wks or 02 wks etc, another words...
01 wks = 1
03 wks = 1
04 wks = 5
05 wks = 2
If I was pulling data directly from HubDB, I would use the selectattr method for example:
{% set table = hubdb_table_rows(xxxxxxx, queryparam) %} {% set wks1 = table | selectattr ("weeks.name","equalto","one") | length %}
The 2 numbers then get added together within my page using {{wks_total}}
Problem is that unlike my example above, the 'wks' column that I want to use doesn't exist in HubDB. The 'wks' column in the table above is a calculation between 2 HubDB columns, therefore how do I split a hubl calculation into more filtered data?
Don't know if this is your whole code so correct me if I'm wrong - but do you have the calculations inside the same for loop as where you're using {{ total_weeks }}? Because if not it's not going to be able to associate the {{ total_weeks }} with the calculations. This worked for me :
{% set table = hubdb_table_rows(XXXXXX) %}
{% for row in table %}
{% set exchanged = unixtimestamp(row.exchange_date) %}
{% set reservation = unixtimestamp(row.reservation_date) %}
{% set exchanged_date = (reservation - exchanged)//24//60//60//1000 %}
{% set total_weeks = (exchanged_date / 7 ) | round %}
Answer = {{ total_weeks }}
{% endfor %}
If this answer solved your question, please mark it as the solution.