cat / 012
clone

a spreadsheet for the terminal: lotus 1-2-3 looks, google sheets keys and formulas, one go binary

main
012 / docs / formulas / tracing.md
tracing.md 4.5K rendered
1---2title: "Tracing formulas"3sidebar_position: 64---56# Tracing formulas78When a number looks wrong, trace it: the cells its formula reads (its9precedents), the formulas that read it (its dependents), and what each10part of the formula computes.1112![Tracing shows what a total reads and what reads it as the pointer moves, then Evaluate formula steps through it](../media/tracing.gif)1314## Showing precedents and dependents1516Data > Formula tracing > Show precedents and dependents (Alt+;) marks them in the grid as17the pointer moves: the cells the active cell's formula reads in green,18the formulas that read the active cell in magenta and bold. Without19color both are in reverse video, dependents bold as well. The context20line lists them all, those off screen with an arrow toward them and21those on other sheets with their sheet (`C7 reads B3, Rate, Data!B2:B9;22read by D7, A40↓, Summary!B2 +3 more`):2324![Tracing on at the total in B7: B3:B5, which it reads, marked green, C7, which reads it, magenta, and the context line listing them, B30 below the screen](../media/trace-view-dark.png#gh-dark-mode-only)25![Tracing on at the total in B7: B3:B5, which it reads, marked green, C7, which reads it, magenta, and the context line listing them, B30 below the screen](../media/trace-view-light.png#gh-light-mode-only)2627Alt+; again stops. What counts as a link:2829| The active cell | Its precedents | Its dependents |30|---|---|---|31| A formula | the cells and ranges it reads, on any sheet; a named range, a region (`nu.sales`) or a [table's](../sheets/tables.md) cells (`Sales[Amount]`) by its name | the formulas that read it through a reference, a range, a named range, a table or a region's name, on any sheet |32| A formula whose array spills | as any formula | the cells it spills into, and the formulas reading any of them |33| A value an array spilled | the formula that spilled it | the formulas reading it |34| A cell of a linked file or of a notebook output sent to the sheet ([regions](../nushell/notebooks.md)) | the file, or the notebook cell | the formulas reading it, `nu.name` included |3536Only direct links show; go to one and tracing shows its own, a level37further. Excel draws arrows between cells; 012 marks the cells and lists38the rest, which reads the same for a range on another sheet or far off39screen.4041## Going to one4243Data > Formula tracing > Go to a precedent or dependent (Alt+') lists44the active cell's precedents, then its dependents, with what each is45(`precedent, named range B2:B9`, `dependent, on Summary`). Type to narrow the46list; Enter goes to one, selecting a range, showing another sheet, or a47notebook's cell. A cell read by more than a thousand formulas lists the48first thousand.4950## Stepping through them5152Alt+, and Alt+. step through the precedents and the dependents, as53Excel's Ctrl+[ and Ctrl+], which terminals send as Esc: the first press54marks them all and jumps to the first, each press after to the next,55and Esc goes back to the cell traced. Cells on hidden sheets are56skipped; when that leaves nothing, the context line names the hidden57sheets ("Reads only Data, a hidden sheet; View > Hidden sheets shows58it").5960## Evaluating a formula step by step6162Data > Formula tracing > Evaluate formula (Alt+=), after Excel's63Evaluate Formula, opens a box over the grid with the active cell's64formula. The part computed next is underlined, and the line under it65says what it computes:6667![Evaluate formula on B8, two steps in: the values computed so far in italic, the next part underlined, and on the line under it what that part computes](../media/evaluate-dark.png#gh-dark-mode-only)68![Evaluate formula on B8, two steps in: the values computed so far in italic, the next part underlined, and on the line under it what that part computes](../media/evaluate-light.png#gh-light-mode-only)6970- Enter puts the value in its place, in italic, and underlines the next71 part, until the formula's value is all that's left; Enter then starts72 over.73- → steps into the underlined part when it's a reference to another74 formula: the box shows that formula, and its title the way in75 (`Evaluate D1 › B1`). ← or Esc steps back out, the reference's value76 in its place. Esc at the first formula closes the box.7778The values are what the formula computes where each part stands: an79array where the part is read as one (`SUM(A1:A9*2)` shows the doubled80column, `{2;4;…}`), names bound inside `LET`, and nothing for the branch81`IF`, `IFERROR` or `CHOOSE` didn't take, which stays as written. A blank82cell reads as 0. The formula is written in the83[locale's](../sheets/locale.md) syntax, spaced as 012 stores it.