Hubdb selectattr filtering.

Hello,
I have in my hubspot code a filter. this works great but now I dont want to have empty filters in my code.
In my hubdb I have a column called “system” with the value rearing
all_items gives back 22 items
I dont want to show the values that have no rows.

 {% set solutionVal2 = module.default_solution %}
 {% set queryparam2 = '&solutions__contains=' + solutionVal2 %} 
 {% set all_items = hubdb_table_rows(module.hubdbtable_field, queryparam2) %}

 {% for choice in types %}
 {% set choice_name = choice.name | regex_replace("[&\\s\\-]", "") %}
 {% set filtered_items = all_items | selectattr('system', 'equalto', 'rearing') %}

 {% set type_list = type_list~choice.id|list %}
 <div class="cat action" results="{{ filtered_items | length }}">
 <label>
 <input type="checkbox" id="{{choice.id}}" name="{{choice.name}}" value="{{choice_name}}"><span>
 <div>
 <svg width="12" height="10" viewBox="0 0 12 10" fill="none" xmlns="http://www.w3.org/2000/svg">
 <path d="M4.81753 6.49487L9.993 0.873976C10.4519 0.375576 11.1924 0.375307 11.6516 0.873374C12.116 1.37708 12.1162 2.19829 11.652 2.70226L5.79809 9.05814C5.25539 9.64738 4.37978 9.64727 3.8372 9.0579L0.347771 5.26749C-0.116169 4.76354 -0.115887 3.94258 0.348399 3.439C0.8077 2.94083 1.54836 2.94127 2.00716 3.43999L4.81753 6.49487Z" fill="white"/>
 </svg>

 </div>{{choice.name}}</span>
 </label>
 </div>

 {% endfor %}

The column “solutions” and “systems” are multiselects

Solution i found:

{% set table_id = module.hubdbtable_field %}
{% set queryparam2 = '&solutions__contains=' + solutionVal2 %}
{% set multiselect_column_name = item.column_name %}
{% set table = hubdb_table_rows(table_id, queryparam2) %}

{% set table_filtered_multiselect = table|selectattr(multiselect_column_name)|map(multiselect_column_name) %}

 {% set used_multiselect_options = [] %}
 {% for item_fil in table_filtered_multiselect %}
 {% for subitem in item_fil %}
 {% do used_multiselect_options.append(subitem) %}
 {% endfor %}
 {% endfor %}

 {# remove duplicates and sort the options #}
 {% set used_multiselect_options = used_multiselect_options|unique|sort(False, False, "order") %}

 {% for tsa in used_multiselect_options %}
 {% set choice_na = tsa.name | regex_replace("[&\\s\\-]", "") %}
 <div class="cat action" results="{{ used_multiselect_options | length}}">
 <label>
 <input type="checkbox" id="{{tsa.id}}" name="{{tsa.name}}" value="{{choice_na}}"><span>
 <div>
 <svg width="12" height="10" viewBox="0 0 12 10" fill="none" xmlns="http://www.w3.org/2000/svg">
 <path d="M4.81753 6.49487L9.993 0.873976C10.4519 0.375576 11.1924 0.375307 11.6516 0.873374C12.116 1.37708 12.1162 2.19829 11.652 2.70226L5.79809 9.05814C5.25539 9.64738 4.37978 9.64727 3.8372 9.0579L0.347771 5.26749C-0.116169 4.76354 -0.115887 3.94258 0.348399 3.439C0.8077 2.94083 1.54836 2.94127 2.00716 3.43999L4.81753 6.49487Z" fill="white"/>
 </svg>

 </div>{{tsa.name}}</span>
 </label>
 </div>
 {% endfor %}