Column name in formula

Hi,

I am trying to have a lookup where one of the conditions is the column name. How do I set that up?

I have one table where all my inventory movement is being recorded (Stock Tracker). I am trying to set up another table (Balances) which will calculate balances of each inventory item at each location. So I want to plug in the location (column header) in the lookup formula. It works when hardcoded, but ideally I want it to be a formula if possible.

https://mayanklhila.getgrist.com/oi2YyHdb7o1E/Untitled-document

Thank you for the help!

Cheers,
M

There isn’t a supported way to get the ID of the current column, but there is a hacky way that happens to work today:

table.table._engine._current_node.col_id

The downside is that it peeks into the internals of the data engine, so there is no guarantee it will continue working in future versions of the code.

That works, thank you!

Hello @Dmitry_Sagalovskiy ,

Is there a formula to get from a table T all columns names ?

By reaching into the internals, yes, you can get that list too:

list(table.table.all_columns)

(or replace table with the name of a particular other table).

As with the “current column” suggestion, the downside is that this is not public interface and there is no guarantee it will continue working in future versions.