Shifting Cell References
A Block Format is authored once and stamped many times, in many places. A formula in one of its templates isn't meant to point at the same literal cell everywhere it lands — a subtotal reading =SUM(A1:A10) in one copy is intended to read =SUM(C1:C10) in the copy two columns over.
To make that work, the cell addresses inside a Block Format's formulas are incremented every time the block is stamped, by however far that copy sits from the block's origin.
The origin
The Matrix scans for matches row by row, left to right, and the first stamp to land becomes that block's origin.
The origin's formulas are used exactly as authored. Every other copy is shifted by its distance from the origin.
In practice this means you should author a block's formulas as though writing them straight into the first place the block will land. Every other copy will be updated automatically from there.
The origin belongs to the Block Format, not to the rule. If two Block Formatting Rules stamp the same block, they share one origin. It depends on whichever of them lands first.
A worked example
A Column block with a single template containing the formula A1+B1, with Extends set so it repeats down the column. It's first stamped so its top cell lands in C1, then stamped again three columns over at F1:
| Cell | Distance from origin | Formula |
|---|---|---|
| C1 | this is the origin | A1+B1 |
| C2 | 1 row down | A2+B2 |
| C3 | 2 rows down | A3+B3 |
| F1 | 3 columns right | D1+E1 |
| F2 | 1 row down, 3 cols right | D2+E2 |
Two things worth noticing:
- Every line an Extends produces is shifted, too. That's what lets one extending template walk down a column summing a different pair of cells on each row.
- The two axes shift independently. F2 is displaced on both, so both its row and its column references move.
Which references shift
A block's formulas follow the same rules as anywhere else in the Matrix: unanchored references like A1 shift on both axes, a $ pins the part that follows it so it stays put in every copy, and labels are never touched. See Cell References.
What isn't shifted
Shifting applies to the formula on a stamped cell. It does not reach formulas that arrive by another route — a Formatting Rule condition or formula, or a writeback formula, attached to the Block Format or its templates. Those keep the addresses they were resolved with against the block's own layout, so they do not follow the block to where it lands.