I am confused about notion filter grouping

Hey,

I am currently working on some automation in notion, I would like to get pages with this filters:


Like you can see I got 12 pages as return, in n8n I made this:

And got 15 pages on return

{
  "nodes": [
    {
      "parameters": {
        "resource": "databasePage",
        "operation": "getAll",
        "databaseId": "e6d56144-06ed-4ac6-9196-a72672264b8f",
        "returnAll": true,
        "options": {
          "filter": {
            "multipleCondition": {
              "condition": {
                "and": [
                  {
                    "key": "Done or cancelled|checkbox",
                    "condition": "equals"
                  },
                  {
                    "key": "Fixed|checkbox",
                    "condition": "equals"
                  },
                  {
                    "key": "Recurring|select",
                    "condition": "is_empty"
                  },
                  {
                    "key": "Date|date",
                    "condition": "on_or_before",
                    "date": "={{new Date().toISOString()}}"
                  }
                ],
                "or": [
                  {
                    "key": "Date|date",
                    "condition": "is_empty"
                  }
                ]
              }
            }
          }
        }
      },
      "name": "Notion1",
      "type": "n8n-nodes-base.notion",
      "typeVersion": 1,
      "position": [
        160,
        1140
      ],
      "credentials": {
        "notionApi": {
          "id": "1",
          "name": "[email protected]"
        }
      }
    }
  ],
  "connections": {}
}

Could some1 please explain to me how to filter correctly pages if I have and and or in one block like I am 5. Because TBH making filters with “groups” is pretty tricky for me, I feel lost

@edit
I don’t understand why for each condition we define and or or. I we have two condition we say “1 or 2” or “1 and 2”, but in n8n we “1 - or, 2 - and”. I don’t got it ;C

Thank you in advance!

Oh wow, that’s a tough one and now that I tried figuring it out my brain hurts :smiley:

As far as n8n is concerned, the filters configuration you have set would be passed on to the Notion API. So when setting something like this in my own workflow’s Notion node:

n8n would send a filter like this to the Notion API:

{
    "filter": {
        "or": [{
            "property": "Abgeschlossen",
            "checkbox": {
                "equals": false
            }
        }],
        "and": [{
            "property": "Status",
            "text": {
                "starts_with": "The shipment "
            }
        }]
    }

So n8n would just take the information and add your filters to the respective API request rather than doing any processing itself. You can actually see the request when setting your log N8N_LOG_LEVEL to debug.

So with this in mind you’d need to check with Notion’s support team how exactly they resolve such API requests. Their documentation simply says “Filters are similar to the filters provided in the Notion UI”.

That said, I am not sure this would give you the like I am 5 answer you are after. So you might save yourself some hassle and simply set the less restrictive OR filters on the Notion node and then do the additional filtering afterwards in n8n using the IF node.

1 Like

So yeah,

I am sorry for your headache :smiley: I already read docs but another article, but this is some useful (useless) xD
I just wrote to notion the support, maybe it will help, I will write here then.

About filtering via function node its good idea, but I get something like 2000 pages from notion and filter them to about 10, so it takes much time. But for now it’s good. Thanks!

1 Like

So, notion updated documentation and I think that this part is easy to understand now: Query a database

Sadly, I believe it’s not possible right now to set deep filter like in docs example in n8n, may I kindly ask to add it to to-do list?

Thanks a lot!

Please open a separate Feature Request for that.

1 Like