# Looping a HubL filter

**URL:** <https://community.hubspot.com/t/looping-a-hubl-filter/51304>\
**Category:** CMS Development\
**Tags:** hubdb\
**Created:** [February 10, 2022, 2:52pm UTC](https://community.hubspot.com/t/looping-a-hubl-filter/51304 "2022-02-10T14:52:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ben-duchy](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ben-duchy/32/84083_2.png) [@ben-duchy](https://community.hubspot.com/u/ben-duchy)\
**Post date:** [February 10, 2022, 2:52pm UTC](https://community.hubspot.com/t/looping-a-hubl-filter/51304/1 "2022-02-10T14:52:52Z")

</div>

Does anyone know a way how to loop a filter? Is it even possible?

I’ve been tasked with building an internal dashboard for my employer to show a variety of data from 30+ locations.

Each filter is complex, but essentially only has a couple of items changed (basic example below). Instead of hardcoding each filter, is it possible to loop it within the module so new filters can be added or removed within the page editor?

```lia-code-sample
{% set filter_london = table | selectattr ("city.name","equalto","London") | rejectattr ("plot_status.name","equalto","Reserved") %}

{% set filter_manchester = table | selectattr ("site.name","equalto","Manchester") | rejectattr ("plot_status.name","equalto","Reserved") %}

{% set filter_glasgow = table | selectattr ("city.name","equalto","Glasgow") | rejectattr ("plot_status.name","equalto","Reserved") %}

```

---

<div class="post-metadata">

**Author:** ![Oezcan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/oezcan/32/53959_2.png) [@Oezcan](https://community.hubspot.com/u/Oezcan)\
**Post date:** [February 10, 2022, 3:47pm UTC](https://community.hubspot.com/t/looping-a-hubl-filter/51304/2 "2022-02-10T15:47:20Z")

</div>

Hello @ben-duchy ,

of course it is possible 🙂

as my solution I would like to link two pages where you will definitely find a solution to your case.  
[Click here](https://developers.hubspot.com/docs/cms/hubl/filters) for the filters supported by HubL. You might want to use one.

[Click here](https://developers.hubspot.com/docs/cms/hubl/for-loops) for the loops.  
And for your case I think you will need this loop.

[Click here](https://developers.hubspot.com/docs/cms/hubl/for-loops#key-value-pairs-in-loops)

I hope I could help, best regards,

Özcan

---

<div class="post-metadata">

**Author:** ![ben-duchy](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ben-duchy/32/84083_2.png) [@ben-duchy](https://community.hubspot.com/u/ben-duchy)\
**Post date:** [February 10, 2022, 3:53pm UTC](https://community.hubspot.com/t/looping-a-hubl-filter/51304/3 "2022-02-10T15:53:43Z")

</div>

Perfect, thank you @Oezcan
