CMS Development

rainism
Mitglied

HubDB - How to combine results of a field

lösung

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?

0 Upvotes
1 Akzeptierte Lösung
lscanlan
Lösung
HubSpot-Alumnus/Alumna
HubSpot-Alumnus/Alumna

HubDB - How to combine results of a field

lösung

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

Lösung in ursprünglichem Beitrag anzeigen

0 Upvotes
3 Antworten
lscanlan
Lösung
HubSpot-Alumnus/Alumna
HubSpot-Alumnus/Alumna

HubDB - How to combine results of a field

lösung

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
0 Upvotes
rainism
Mitglied

HubDB - How to combine results of a field

lösung

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

0 Upvotes
rainism
Mitglied

HubDB - How to combine results of a field

lösung

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

0 Upvotes