'Rollup of rollup in Notion API

I have rollup from one database to another and I need to have a number from that rollup in the third database. Since Notion doesn't support rollup to rollup, I've created a formula that simply refers to rollup property, and third database has a rollup to this formula property. In the UI everything works fine, values are shown as they supposed to, but when I get a page in the API that property returns null instead of number:

{
    "Rollup Property": {
        "id": "O%40qR",
        "type": "rollup",
        "rollup": {
            "type": "array",
            "array": [
                {
                    "type": "formula",
                    "formula": {
                        "type": "number",
                        "number": null
                    }
                }
            ],
            "function": "show_original"
        }
}

It is not an access problem - if I create a rollup to other properties, they returns just fine. What seems to be the problem?



Solution 1:[1]

The issue of Notion unable to refer to rollups correctly is well established from a while, and it gets more confusing while using the API, unfortunately.

Here's what Notion's support says:

There are a couple known limitations with roll-ups and formulas in the API.

  • Formulas and roll-ups can only support a maximum of 25 references. This limitation is removed for roll-ups if you use the GET /page property endpoint and paginate through the result set. The last value in that result set should be correct. There is no alternative for formulas.

  • Both roll-ups and formulas can only reference values 1 level deep. If your properties rely on nested values then the values will be inaccurate. For example if you have a formula that requires property A, which in turn requires a value from property B to computer that would be nested. Essentially any relationship where A requires B and B requires C to calculate is nested

The alternative hence, is to link the third database with the first and second and rollup the property(s) to do the computation in a formula on third.(Assuming you need some value from first and second)


A few other projects that rely on the functionality have it on hold, see: https://github.com/jamalex/notion-py/issues/76

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Angaj Sharma