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

# Formulas & Magic Formula

> The full formula system in Tablix, the Formula Bar and function autocomplete, and the AI-powered Magic Formula generator.

Tablix has two ways to write formulas: **type them yourself** with full autocomplete support, or describe what you want in plain English and let **Magic Formula** write it for you.

## Writing Formulas Yourself

Start any cell entry with `=` to begin a formula. As you type:

* The **Formula Bar** (top of the grid, marked `fx`) mirrors what you're typing in the active cell
* Any cell references or ranges inside the formula (e.g. `A1`, `B2:B10`) are **color-coded**, and the matching ranges are highlighted directly on the grid so you can see what you're referencing
* **Autocomplete** — typing a partial function name (e.g. `SU`) shows a matching-functions dropdown (`SUM`, `SUMIF`, `SUMIFS`, ...); use arrow keys + `Enter`/`Tab` to accept
* **Parameter hints** — once you open a function's parentheses (e.g. `=VLOOKUP(`), a hint box shows that function's parameters and highlights which one you're currently typing

### Function Categories

<AccordionGroup>
  <Accordion title="Math">SUM, PRODUCT, ROUND, trig functions, logs, etc.</Accordion>
  <Accordion title="Statistical">AVERAGE, MEDIAN, STDEV, CORREL, FORECAST.LINEAR, PERCENTILE, RANK, etc.</Accordion>
  <Accordion title="Logical">IF, IFS, AND, OR, SWITCH, IFERROR, IFNA, etc.</Accordion>
  <Accordion title="Information">ISBLANK, ISNUMBER, ISERROR, TYPE, etc.</Accordion>
  <Accordion title="Text">LEFT/RIGHT/MID, CONCAT, TEXTJOIN, SPLIT, SUBSTITUTE, TEXT, TRIM, etc.</Accordion>
  <Accordion title="Date & Time">DATE, TODAY, NOW, NETWORKDAYS, WORKDAY, DATEDIF, EDATE, EOMONTH, etc.</Accordion>
  <Accordion title="Financial">PMT, FV, PV, NPV, IRR, XIRR, SLN/DDB/VDB, bond/security functions, etc.</Accordion>
  <Accordion title="GST">GST, ADDGST, REMOVEGST, CGST, SGST, IGST, GSTBREAKUP, etc.</Accordion>
  <Accordion title="Engineering">Base conversions, bitwise operations, complex numbers, CONVERT, etc.</Accordion>
  <Accordion title="Lookup & Reference">VLOOKUP, HLOOKUP, XLOOKUP, INDEX, MATCH, INDIRECT, OFFSET, etc.</Accordion>
  <Accordion title="Array">ARRAYFORMULA, FILTER, SORT, UNIQUE, SEQUENCE, MMULT, TOROW/TOCOL, etc.</Accordion>
  <Accordion title="Database">DSUM, DAVERAGE, DCOUNT, DGET, DMAX/DMIN, etc.</Accordion>
  <Accordion title="Lambda">LAMBDA, MAP, REDUCE, BYROW, BYCOL, SCAN, MAKEARRAY.</Accordion>
</AccordionGroup>

<Tip>
  Open the **Functions** sidebar any time to browse every function by category with its syntax and an example.
</Tip>

## Magic Formula (AI-Generated Formulas)

**Magic Formula** lets you describe a calculation in plain English (or by voice) right next to a cell, and generates the actual formula for you — with a live preview before you commit to it.

### Opening Magic Formula

Right-click a cell and choose **Magic Formula** from the context menu. A small prompt box opens anchored to that cell.

### Column vs. Row Mode

<Tabs>
  <Tab title="Column mode (default)">
    Use when your data runs **above** the active cell. Magic Formula automatically detects the contiguous data block directly above the cell (skipping over a header row if one is detected) and targets that range.
  </Tab>

  <Tab title="Row mode">
    Use when your data runs **to the left** of the active cell, in the same row (e.g. a "Total" cell at the end of a row). Magic Formula reads the header row above plus the current row's values to the left of the active cell.
  </Tab>
</Tabs>

Toggle between **Col** and **Row** with the buttons at the top of the prompt box.

### Describing What You Want

Type a request like:

* *"sum of cells above"*
* *"average"*
* *"total of this row"*
* *"profit margin"* (Revenue/Profit columns detected from context)

Or click the microphone icon to dictate it — this uses your browser's speech recognition and auto-stops after a few seconds of silence (see [Troubleshooting](/troubleshooting#speech-recognition-is-not-supported-in-your-browser) if voice input isn't available).

### Reviewing & Inserting

After you submit, Magic Formula shows a confirmation view with:

* The **exact formula** it generated (e.g. `=SUM(C2:C9)`)
* A **live preview** of what that formula would evaluate to right now, so you can sanity-check it before inserting
* **Edit** — go back and adjust your original prompt
* **Insert Formula** — commit it into the active cell

<Info>
  Behind the scenes, Magic Formula follows a few built-in conventions so results are predictable:

  * **Percentages, margins, rates, and ratios** are always multiplied by 100 and rounded to 2 decimals (e.g. a profit-margin request becomes `=ROUND((P2/N2)*100, 2)`, not a raw `0.24` ratio).
  * **Any division/decimal result** is wrapped in `ROUND(..., 2)` for a clean output.
  * It prefers the **automatically detected data range** above or beside the cell over guessing a range from scratch.
</Info>

<Note>
  Like other AI features, Magic Formula is branded as **TablixAI** and won't reference the underlying model provider if asked. Always check the live preview before inserting, especially for financial calculations.
</Note>
