Evaluate formula
evaluate_formulaTest an Excel formula against sample cell values and return the computed result, type, and stats to verify logic before adding it to a workbook.
Instructions
Evaluate an Excel formula and return the computed result: a quick way to check what a formula returns on a few sample values before you put it in a workbook. Pass data as a map of cell references to values (e.g. {"A1": 100, "A2": true, "A3": "#N/A", "B1": "hello"}) and a formula string (e.g. "SUM(A1:A2)"). Values keep their Excel types, as in a workbook: true/false are logical cells (so SUM, AVERAGE and COUNT skip them in a range), a string that is exactly an error code (#N/A, #DIV/0!, #VALUE!, #REF!, #NAME?, #NUM!, #NULL!) is that error, and other strings are text. The formula is placed in row 1 of the first column right of your data, so don't reference that cell. Returns {formula, result, type, stats}, type being "number", "string", "boolean" or "error". A formula that evaluates to an Excel error returns type "error" with the code (#VALUE!, #N/A…) as a normal result; a formula that can't be parsed or uses an unsupported function is a tool error. Supports 278 Excel functions: math, financial (NPV, IRR, XIRR, PMT, PRICE, YIELD…), statistical distributions, regression, lookup, date/time, text, logical, and dynamic arrays (FILTER, SORT, UNIQUE, SEQUENCE, CHOOSECOLS, TAKE, DROP). Array expressions evaluate element by element inside SUMPRODUCT, LOOKUP, AGGREGATE, SMALL/LARGE, MATCH and INDEX. To check formulas that already live in a workbook, use create_session instead. Runs on the Basis API (needs an API key).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | No | Cell data to populate before evaluating. Keys are cell references like "A1", "B2". Values are numbers, booleans (logical TRUE/FALSE), error codes such as "#N/A", or text. | |
| formula | Yes | Excel formula to evaluate (without the leading '='), e.g. "SUM(A1:A2)" or "NPV(0.08,B1:B5)" |