Reference cells

Reference cells from JavaScript.

In Quadratic, reference tables and named outputs for simplest reference, reference individual cells from JavaScript for single values or reference a range of cells for multiple values.

Referencing tables (and named outputs)

To reference a table, use the global function q.cells along with the table's name in the fashion outlined below.

// NOTE: uses the same A1 notation as Formulas
// References existing Table1 and is read in as array of arrays
let x = q.cells("Table1")

// Get a single column out of table into an array
let x = q.cells("Table1[column_name]")

// Get the table headers 
let x = q.cells("Table1[#HEADERS]")

// Reference a range of columns in a table
let x = q.cells("Table_name[[column_name:column_name]]")

Referencing individual cells

To reference an individual cell, use the global function q.cells which returns the cell value.

Any time cells dependent on other cells update, the dependent cell will also update. This means your code will execute in one cell if it is dependent on another. This is the behavior you want in almost all situations, including user inputs in the sheet that cause calculation in a JavaScript cell.

Referencing a range of cells

To reference a range of cells, use the same global function q.cells() which returns an array of arrays.

Referencing another sheet

To reference another sheet's cells or range of cells use the following:

Unbounded ranges

Unbounded column references

To reference all the data in a column or set of columns without defining the range, use the following syntax.

Column references span from set row (row 1 if not defined) to wherever the content in that column ends.

Unbounded row references

To reference all the data in a row or set of rows without defining the range, use the following syntax.

Row references span from the row set to wherever the content in that row ends.

Relative vs absolute references

By default when you copy paste a reference it will update the row reference unless you use $ notation in your references.

Last updated

Was this helpful?