# Flexible table data

**URL:** <https://community.hubspot.com/t/flexible-table-data/23233>\
**Category:** CMS Development\
**Created:** [July 22, 2020, 10:31am UTC](https://community.hubspot.com/t/flexible-table-data/23233 "2020-07-22T10:31:51Z")\
**Posts on this page:** 8\
**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:** [July 22, 2020, 10:31am UTC](https://community.hubspot.com/t/flexible-table-data/23233/1 "2020-07-22T10:31:51Z")

</div>

Is it possible to add a choice field within the ‘set table’ line?

Currently I have the following line of code which works fine:

**{% set table = hubdb\_table\_rows(module.table\_id, “plot-status=Released&orderBy=class”) %}**

However I would like to add in a choice field **{{ module.plotstatus }}** to allow the content editor to select which hubdb data to display. Is this possible?

I’ve tried replacing **"plot-status="Released** with

**plot-status={{ module.plotstatus }}** but it doesnt work!  
Thanks in advance

---

<div class="post-metadata">

**Author:** ![piersg](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/piersg/32/99782_2.png) [@piersg](https://community.hubspot.com/u/piersg)\
**Post date:** [July 22, 2020, 12:00pm UTC](https://community.hubspot.com/t/flexible-table-data/23233/2 "2020-07-22T12:00:17Z")

</div>

Hi @ben-duchy

You could try this:

`{% set choice = module.plotstatus %}{% set table = hubdb_table_rows(module.table_id, "plot-status=" ~ choice ~ "&orderBy=class") %}`

---

<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:** [July 22, 2020, 12:27pm UTC](https://community.hubspot.com/t/flexible-table-data/23233/3 "2020-07-22T12:27:25Z")

</div>

Genius! Thanks very much.

In addition to this, is it possible build on this command to pull in extra data _but_ only if a particlar selection is made?

As it stands the relevant row will only show if the content editor selects it, but if they select for example “Available” from the choie field, can it also show “SpecialOffer” fields too and vice versa?

---

<div class="post-metadata">

**Author:** ![piersg](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/piersg/32/99782_2.png) [@piersg](https://community.hubspot.com/u/piersg)\
**Post date:** [July 22, 2020, 1:26pm UTC](https://community.hubspot.com/t/flexible-table-data/23233/4 "2020-07-22T13:26:23Z")

</div>

So you want to add an aditional filter, SpecialOffer, to the table call when “Available” is selected from the plot status choice?

```auto
{% set choice = module.plotstatus %}{% if choice == "Available" %} {% set choice = choice ~ "&SpecialOffer=[value]" %}{% endif %}
{% set table = hubdb_table_rows(module.table_id, "plot-status=" ~ choice ~ "&orderBy=class") %} 

```

---

<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:** [July 22, 2020, 2:15pm UTC](https://community.hubspot.com/t/flexible-table-data/23233/5 "2020-07-22T14:15:05Z")

</div>

Yes thats correct - I’m trying to get it to pull in both sets of data but only if ‘Available’ is selected.

This hasn’t worked, but I see where you’re going with it, so thanks all the same.

I’ll see if I can figure it… out unless you have any other ideas?

---

<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:** [July 22, 2020, 2:26pm UTC](https://community.hubspot.com/t/flexible-table-data/23233/6 "2020-07-22T14:26:54Z")

</div>

@piersg I’ve found a fix, although probably not the prettiest coding I’ve ever done…

{% set choice = module.select\_status %}  
{% if choice == “Available” %}  
{% set table = hubdb\_table\_rows(module.table\_id, “&plot-status\_\_in=Available,SpecialOffer&orderBy=price&orderBy=class”) %}  
{% else %}  
{% set table = hubdb\_table\_rows(module.table\_id, “plot-status=” ~ choice ~ “&orderBy=class”) %}  
{% endif %}

---

<div class="post-metadata">

**Author:** ![piersg](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/piersg/32/99782_2.png) [@piersg](https://community.hubspot.com/u/piersg)\
**Post date:** [July 22, 2020, 2:54pm UTC](https://community.hubspot.com/t/flexible-table-data/23233/7 "2020-07-22T14:54:52Z")

</div>

Haha well if it works, it works. In my earlier response I didn’t understand that “SpecialOffer” was also an option from plot-status, so apologies for that.

If you wanted to cut a couple of lines you could do this:

```auto
{% set choice = "plot-status=" ~ module.select_status %}
{% if choice is string_containing "Available" %}
 {% set choice = "&plot-status__in=Available,SpecialOffer&orderBy=price" %}
{% endif %}
{% set table = hubdb_table_rows(module.table_id, choice ~ "&orderBy=class") %}

```

---

<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:** [July 22, 2020, 2:59pm UTC](https://community.hubspot.com/t/flexible-table-data/23233/8 "2020-07-22T14:59:34Z")

</div>

Thanks @piersg, I’ll give it a go when I get a sec - thanks again for your help previously
