HubDB - How to combine results of a field

SOLVE
Highlighted
Regular Contributor

How to combine results of a column (it has the same value for all of the rows) so I can print it only once in my template?

Reply
0 Upvotes
1 Accepted solution

Accepted Solutions
Highlighted
HubSpot Alumni

Hi @rainism,

 

I'm happy to help with this one, but can you give more specifics in your example? I'm not entirely sure I'm understanding what your data look like. What's the column type that you're working with and what are you combining? If you only need to print the column once, could you throw it inside of a conditional that looks for the loop index while looping through all of the table's rows? For example something like this:

 

{% if loop.first %}
  {# print your column value here #}
{% endif %}

Or could you use the hubdb_table_rows function to create a dictionary of only one of the table's rows? That function is documented here: https://designers.hubspot.com/en/docs/hubl/hubl-supported-functions#hubdb-table-row. That could be off-base depending on what you're trying to do, so feel free to add some more context here.

Leland Scanlan

HubSpot Developer Support
Reply
0 Upvotes
3 Replies 3
Highlighted
HubSpot Alumni

Hi @rainism,

 

I'm happy to help with this one, but can you give more specifics in your example? I'm not entirely sure I'm understanding what your data look like. What's the column type that you're working with and what are you combining? If you only need to print the column once, could you throw it inside of a conditional that looks for the loop index while looping through all of the table's rows? For example something like this:

 

{% if loop.first %}
  {# print your column value here #}
{% endif %}

Or could you use the hubdb_table_rows function to create a dictionary of only one of the table's rows? That function is documented here: https://designers.hubspot.com/en/docs/hubl/hubl-supported-functions#hubdb-table-row. That could be off-base depending on what you're trying to do, so feel free to add some more context here.

Leland Scanlan

HubSpot Developer Support
Reply
0 Upvotes
Highlighted
Regular Contributor

Hello @lscanlan, and thank you for trying to help.

My column type is Date, and I need it to filter and group the data in rows by date.

Some of the rows have the same date in which case I have to print it only once so later I can turn them into separate blocks under the same date.

Screenshot_1.png

Reply
0 Upvotes
Highlighted
Regular Contributor

I guess I managed to solve the problem by grouping my data by a particular column.
Anyway thank you for help.

Reply
0 Upvotes