I use the cloud version and I have an issue when trying to get data coming from a rollup formula from a local python script.
To reproduce the bug I created a two table database. Below is the full debug base structure
— COMPLETE BASE STRUCTURE WITH ALL BASES AND COLUMNS —
.
Table: Main (ID: 0000)
→ ID (text)
→ Children (link → 0000)
→ Sub (link → p5f8)
→ SubValues (link-formula)
→ Cumul (formula)
→ RollUpTest1 (formula)
→ RollUpTest2 (formula)
→ Value (number)
→ SingleTableCumul (formula)
→ RollUpTest3 (formula)
→ OtherCumul (formula)
.
Table: Sub (ID: p5f8)
→ ID (text)
→ Main (link → 0000)
→ Value (number)
The main table looks like this. The minimum required fields are ID, Children and Cumul. The others are only for debug.
The data in the main table is a tree structure
- M001
- M002
- M003
- M004
Each record get values from the Sub Table (VXXX records). Cumul is for a level the sum of the VXXX values directly related to the record and the sum related to its children.
- Cumul = rollup(“Sub”,“Value”,“sum”) + rollup(“Children”,“Cumul”,“sum”)
It works well (or seems to) but I have issues when trying to read the Cumul values from a script
Below is the first basic script I used
from seatable_api import Base, context
import json
import pandas as pd
server_url = context.server_url
api_token = context.api_token
base = Base(api_token, server_url)
base.auth()
json_data = base.query(‘select * from Main’)
main = pd.DataFrame(json_data)
print(main[[‘ID’,‘Cumul’,]])
This is what I get from the script
ID Cumul
0 M001 None
1 M002 None
2 M003 None
3 M004 None
I get a None value for Cumul (which is not what I have on the screen).
I tried other formulas, even implementing a version where the values come from the same table to try to understand where is the problem. Below is the new full debug table, the tested formulas and the results from the new script.
- RollUpTest1 = rollup(“Sub”,“Value”,“sum”)
- RollUpTest2 = rollup(“Children”,“RollUpTest2”,“sum”)
- SingleTableCumul = {Value} + rollup(“Children”,“SingleTableCumul”,“sum”)
- RollUpTest3 = rollup(“Children”,“Value”,“sum”)
- OtherCumul = {RollUpTest3}+{Value}
ID Cumul RollUpTest1 RollUpTest2
0 M001 None NaN None
1 M002 None 12.0 None
2 M003 None 20.0 None
3 M004 None 15.0 None
ID Value SingleTableCumul RollUpTest3 OtherCumul
0 M001 0 None 32.0 32
1 M002 12 None NaN 12
2 M003 20 None 15.0 35
3 M004 15 None NaN 15
It seems that the problem arise when I used a rollup formula in a “recursive way”.
- RollUpTest2 = rollup(“Children”,“RollUpTest2”,“sum”)
The problem is only when trying to get the values from a script. The only way I found to deal with this is to … copy/paste the data in other columns by hand !
I can provide the full debug database (dtable file) if somebody tells me how to do it !