> ## Documentation Index
> Fetch the complete documentation index at: https://calcs.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Learn How to Reference Tables in Equations

> After you add a table widget, use its reference ID in other widgets with matrixSubset, col, T(), and related patterns.

You added a **table widget** and gave it a **reference ID** (for example `loads` or `beam_data`). This guide shows how to **use that table in other widgets**—computed fields, checks, or any equation.

Think of the table like a **spreadsheet**: rows, columns, and cells. In equations, the reference ID is the **name of the whole block of numbers**.

<Tip>
  **Start here:** The reference ID is how you “call” the table from anywhere else. You usually do not use the raw matrix by itself—you pull **one cell**, **one column**, or an **aggregate** (max, min, sum) with the patterns below.
</Tip>

## Jump to a section

<CardGroup cols={2}>
  <Card title="Reference ID" icon="hashtag" href="#reference-id">
    How the table name is used in equations
  </Card>

  <Card title="One cell" icon="table-cells" href="#one-cell-with-matrixsubset">
    Single value with matrixSubset
  </Card>

  <Card title="One column" icon="bars" href="#one-column-with-col">
    Whole column, then max / min / sum
  </Card>

  <Card title="Vectors" icon="grip-lines" href="#vectors-with-vectorsubset">
    Flat lists with vectorSubset
  </Card>

  <Card title="Inside the table" icon="pen-to-square" href="#inside-the-same-table">
    T(), rowIndex, and 0-based indices
  </Card>

  <Card title="Lookup widgets" icon="magnifying-glass" href="#lookup-widgets">
    L() instead of matrixSubset
  </Card>
</CardGroup>

***

## Reference ID

Every table widget has a **reference ID** you choose (or that comes from the template). That name is how you point at the table from anywhere else.

**Example:** Your table’s reference ID is `loads`.

In another widget’s equation, writing **`loads`** means: “use the **entire table** as one block of data.” You rarely want only that—you usually want **one cell**, **one column**, or a **sum** across rows. The next sections show how.

***

## One cell with matrixSubset

Use **`matrixSubset`** when you need a **single value** at a specific row and column.

* Count rows and columns starting from **1** (first row = 1, first column = 1).

**Pattern:**

```text theme={null}
matrixSubset(loads, rowNumber, columnNumber)
```

**Example — first row, third column:**

```text theme={null}
matrixSubset(loads, 1, 3)
```

**Example — inside a larger formula:**

```text theme={null}
abs(matrixSubset(loads, 1, 3))
```

That is the usual way to pull **one cell** from a normal table using its reference ID.

<Note>
  Full syntax and examples: [Equation Functions](/calcs_builder/equation_functions) (`matrixSubset`).
</Note>

***

## One column with col

Sometimes every row has a value in the same column (for example “deflection” down the table). Use **`col`** to take **that whole column**, then wrap it in **`max`**, **`min`**, **`sum`**, etc.

* Column numbers start at **1** for the **leftmost** column.

**Pattern:**

```text theme={null}
max(col(loads, columnNumber))
```

**Example — largest value in column 6:**

```text theme={null}
max(col(loads, 6))
```

If the table comes from a **remote** result and you need to wrap it (as in some templates), you might see `matrix(...)` around the reference—follow the same idea: **pick the column number**, then **aggregate**.

<Note>
  Details: [Equation Functions](/calcs_builder/equation_functions) (`col()`).
</Note>

***

## Vectors with vectorSubset

If something is already a **flat list** of numbers (not a full table), use **`vectorSubset`**. Positions are counted from **1**.

**Pattern:**

```text theme={null}
vectorSubset(someList, position)
```

Use this when the data is **one row or one list**, not a 2D table.

***

## Inside the same table

When the equation lives **in a column of that same table** (for example a computed column), you do **not** use the reference ID for “the cell to my left.” You use **`T`**, **`rowIndex`**, and **`colIndex`**.

* **`T(row, column)`** refers to a cell **in this table**.
* Inside the table, row and column indices start at **0** (first column = 0, first row = 0).

**Examples:**

* Current row, first column: `T(rowIndex(), 0)`
* Current row, second column: `T(rowIndex(), 1)`

<Warning>
  **Indexing:** Outside the table, **`matrixSubset`** and **`col`** use **1-based** row and column numbers. Inside the table, **`T()`** uses **0-based** indices. Easy to mix up—pick the rule that matches *where* you are writing the equation.
</Warning>

<Note>
  More detail: [Equation Functions](/calcs_builder/equation_functions) (`T()`).
</Note>

***

## Lookup widgets

**Lookup** and **shared lookup** widgets use **`L(referenceId, column)`**, not `matrixSubset`. The column index for **`L`** starts at **0** for the left column. That is a different widget type than a normal editable table.

See [Lookup Widget](/calcs_builder/widgets/lookup_widget) and [Equation Functions](/calcs_builder/equation_functions) (`L()`).

***

## Cheat sheet

| What you want                | Where you write it            | How                                                      |
| ---------------------------- | ----------------------------- | -------------------------------------------------------- |
| One cell from **your** table | Another widget                | `matrixSubset(MyTable, row, col)` — rows/cols from **1** |
| Whole column, then e.g. max  | Another widget                | `max(col(MyTable, col))` — col from **1**                |
| One item from a list         | Another widget                | `vectorSubset(list, n)` — n from **1**                   |
| A cell in the **same** table | Computed column in that table | `T(row, col)` — from **0**                               |

***

## Optional: loops and growing tables

If the table can grow or shrink and you need to add up every row, templates often use **`setSum`** with **`size`** and **`matrixSubset`**. That is a more advanced pattern; the important part is still: **your table’s reference ID is the handle**, and **`matrixSubset`** / **`col`** are how you read from it.

<Accordion title="When to reach for setSum + size">
  Use this when you cannot hard-code row numbers and need to iterate over all rows (for example summing a column dynamically). Start from [Equation Functions](/calcs_builder/equation_functions) and existing templates that use `setSum` for a full pattern.
</Accordion>

***

## Related articles

<CardGroup cols={2}>
  <Card title="Table Widget" icon="table" href="/calcs_builder/widgets/table_widget">
    Configure tables, columns, and reference IDs
  </Card>

  <Card title="Equation Functions" icon="calculator" href="/calcs_builder/equation_functions">
    matrixSubset, col, L, T, and more
  </Card>

  <Card title="Lookup Widget" icon="magnifying-glass" href="/calcs_builder/widgets/lookup_widget">
    When to use L() instead of a normal table
  </Card>

  <Card title="math.js background" icon="code" href="https://github.com/ClearCalcs/dev-environment/wiki/Engineering%3A-Background-and-Setup">
    Base math library used in equations
  </Card>
</CardGroup>
