I am trying to build a query to fetch some entries which I want filter on a table field between multiple values. The table field is "filterTestWidth" and has 1 col named "size" (number type). There are multiple entries with multiple values in col1.

{% set items = craft.entries({
    "section": "catalog",
    "filterTestWidth": [
        "> 180",
        "< 190"
}) %}

Unfortunate the Craft manual is limited on this subject. Does anyone know a more detailed article about element criteria?

1 Answer 1


Table fields in Craft just store their data in a JSON blob in the content table. That means you can't really query them like you would other things, you'd have to load in all of the data, and then filter it out as an array.

While you can certainly do this in Twig, it smacks of a bit too much "business logic" in Twig; so at this point I might be considering one of two options:

  1. Refactoring it out to a plugin or module that will do the heavy lifting behind the scenes

  2. Changing the schema I'm using to store the data in something that can be queried, such as moving the data into entries or a matrix block or perhaps a SuperTable

Or if either of these seems like too much work, or you're not storing a whole lot of data in the Table field, then I'd just do it in Twig by looping through all of the rows in the table, and selecting only the ones that meet my criteria.

  • Thanks for the clarification. I have used super tables before, great plugin! Do you know a good example or an article about filtering with supertables?
    – RvdB
    Commented Aug 12, 2018 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.