Example of global variable

I cannot find a way to use global variable with grist, can you give me an example with simple table A, B?

There’s nothing specifically for global variables, although it is something we would like to add. Here’s a workaround:

  • Make a table that you decide will only be used for global variables - let’s call it Global.
  • Make a field for each global variable you want.
  • Have just one record in that table. A card widget is good for this.
  • Get that single record in other formulas with Global.lookupOne()
  • Get attributes from that record, so a formula might look like g = Global.lookupOne(); return $value / g.total
1 Like

And how to change Global variables from other cells of other tables?

Interesting… Do you mean a variable in the Python sense, not a piece of data as in globally accessible data cell? Could you describe in more detail how you envision it working?

I mean the “global variable” in python
For example, we set ‘STATE’ is the global variable, the table with collumn A, B:

STATE = 1

  • Collumn B: a button can change ‘STATE’ base on 5-7 conditions. So ‘STATE’ will have many values in specific cases
    -Collumn A: if STATE = ‘PLAY’, do XYZ, then set STATE = ‘STOP’, return …

=>This ‘STATE’ variable can be read and writen from any other tables