CMS Development

Top Contributor

Show number of matching rows as a number

Apologies if this has been asked already, but I cannot find any information that can help me solve this.


I am building a custom website module that references the rows within HubDB. It will display how many rows meet a set criteria such as the location (example below). 


{% set no_sites = table | selectattr ("","equalto","Bowgreave") | length %}

Number of Sites located in Bowgreave = {{ no_sites }} <!-- correctly shows 44 -->


Since the above worked, I decided to use it as a guide and instead tried using a date column to see how many meetings are on a specific date, but unfortunately it didn't work! (see below)


{% set no_dates = table | selectattr ("close_date | datetimeformat('%e/%m/%Y')","equalto","28/05/2021") | length %}

Show number of meetings with this date = {{ no_dates }} <!--Should show 10 -->


Placing the date inside a text field within HubDB and removing the datetimeformat from the above code seemed to work, but the moment it's placed within a date field and using the above datetime code, nothing displays! I assume I've not coded it correctly to compensate for this field type, but as yet I'm unable to figure it out. Does anyone know what I'm doing wrong?


Thanks in advance.

4 Replies 4
Top Contributor

Show number of matching rows as a number

Hi @dennisedson , I always wondered why my avatar was that... but I've grown to like it 😂.


Thank you both - @dennisedson  @amwilie - for your ideas.


@amwilie, unfortunately neither solution worked, but I think your on the right track with this. I've used similar methods in the past, but never with date fields.


I'll keep working at it but in the meantime if you have any other ideas please let me know.

Key Advisor | Elite Partner
Key Advisor | Elite Partner

Show number of matching rows as a number

@ben-duchy Have you tried setting the datetime in it's own variable and then using the variable inside the selectattr instead?


{% set close_date_format = close_date|datetimeformat('%e/%m/%Y') %}
{% set no_dates = table|selectattr(close_date_format,"equalto","28/05/2021")|length %}


If this answer solved your question, please mark it as the solution!

Alyssa Wilie

Web Developer at Lynton

explore hubspot themes from lynton

Need custom website/integration development or help optimizing HubSpot for your organization?
Schedule a consultation with us, an award-winning HubSpot Elite Partner.

Or check out our blog to get the latest in marketing, design, integration, and HubSpot knowledge.


HubSpot Product Team
HubSpot Product Team

Show number of matching rows as a number

i loathe how much better @amwilie is than I am 🤣

HubSpot Product Team
HubSpot Product Team

Show number of matching rows as a number

Hi @ben-duchy 

First of all, I do not know why, but I have associated that gorilla avatar exclusively with you even though many other people are randomly assigned it.  (is it random, I forget) 

But you don't give a darn about that. 

The reason it is not working is that I don't think you can use that datetime filter there.  I won't be able to tell you the technical reason.  Probably because it is just an array at this point and you are not targeting the value 🤔

I haven't had the time to work out the human readable filter part, but hopefully this gets you started.  Maybe @Anton  or @amwilie who are both better at this than I am can take over

{% set date = hubdb_table_rows(4024615) %}
{% set dated = date|selectattr("dated") %}
{% for row in dated %}
  {% set test = 1617667200000 %} 
  {% if row.dated == test && loop.last %} 
  There are {{ loop.length }} rows in this table with {{test|datetimeformat('%e/%m/%Y')}}   as the date<br>
  {% endif %}
{% endfor %}