Skip to content

Formula Field (Formula) ​

Formula fields automatically calculate and display results through expressions, supporting references to other fields in the current record, built-in functions, and nested calculations — plus [Table].[Field] column references for cross-table aggregation over data in other tables within the same Base. They are suitable for scenarios requiring automatic calculation, such as total price, completion rate, overdue reminders, and cross-table summaries.

When to Use ​

  • Calculate order total: Quantity × Unit Price
  • Calculate task completion rate: Completed ÷ Total
  • Concatenate display text: First Name + Last Name
  • Determine date status: IF({Due Date} < TODAY(), "Overdue", "On Track")
  • Cross-table summary: sum a column in another table SUM([Sales].[Amount])
  • Conditional counting: count matching records in another table COUNTIF([Sales].[City], "Beijing")

Creating a Formula Field ​

  1. Click Add Field in a table.
  2. Select the Formula field type.
  3. Enter an expression in the formula editor:
    • Reference fields in the current table: click a field name in the Available Fields area to insert {Field Name};
    • Reference other tables: pick a table in the Cross-Table References area, then click a field name to insert [Table Name].[Field Name].
  4. Configure the result format (such as number precision, date format, etc.).
  5. Click Save. The system validates syntax and references on save (whether fields exist, whether column references are valid) and reports problems immediately.

Formula Editor ​

SmartTable provides a formula helper component to lower the barrier of writing formulas:

  • Available Fields: Click to insert a reference to a field in the current record, {Field Name}.
  • Cross-Table References: Choose another table in the same Base, then click a field name to insert a [Table Name].[Field Name] column reference.
  • Function List: Displays all 76 built-in functions by category; hover to view syntax, parameters and examples; click to insert.
  • Syntax Validation: Validates syntax, field references and column references before saving.
  • Real-time Preview: Preview calculation results before saving.

Syntax Rules ​

Field References ​

Reference a field value of the current record using braces:

{Quantity} * {Unit Price}
  • Field names are case-insensitive.
  • Missing fields evaluate to null.

Column References (Cross-Table References) ​

Use [Table Name].[Field Name] to reference the entire column of values (an array) of a field in another table:

SUM([Sales].[Amount])
RuleDescription
ScopeOnly tables within the same Base; cross-Base or missing tables evaluate to 0 / null
CaseTable and field names are case-insensitive; leading/trailing spaces are ignored
Current tableReferences to the current table must still include the full table name (e.g. [Tasks].[Hours])
Referenceable columnsAny raw-value field (number, text, date, single select, checkbox, etc.)
Non-referenceable columnsFormula, lookup and link fields (their computed values are not stored, so column references return nothing)
RenamingRenaming a table or field does not automatically update column references in formulas — update them manually
EvaluationComputed in real time by the server when records are read, so results always match the source table

CurrentValue (Condition Traversal) ​

In the criteria argument of condition functions (FILTER / COUNTIF / SUMIF / AVERAGEIF), CurrentValue represents the current element being visited in the column:

COUNTIF([Sales].[Amount], CurrentValue > 100)
  • CurrentValue is only allowed in the criteria argument of the four functions above.
  • Only the cell-value form is supported (e.g. CurrentValue > 100, CurrentValue = "Beijing"); CurrentValue.[Field] is not supported yet.

Operators and Precedence ​

PrecedenceOperatorDescriptionExample
1 (highest)( )Parentheses first({a} + {b}) * 2
2^Exponentiation2 ^ 10
3* /Multiply, divide{Unit Price} * {Quantity}
4+ -Add, subtract{a} + {b}
5= <> > < >= <=Comparison, returns boolean{Score} >= 60
  • Operators of the same precedence associate left to right.
  • Strings compare lexicographically; when a number is compared with a numeric string, the string is automatically converted to a number (e.g. a stored value of "150.5" still compares correctly with > 100).

Built-in Functions ​

The SmartTable formula engine provides 76 built-in functions (identical on both the client and server engines) and supports common operators, covering five categories:

Operators ​

Besides functions, the formula helper also offers common operators under the "Operators" category:

OperatorSymbolDescriptionExample
ADD+Addition{Unit Price} + {Shipping}
SUBTRACT-Subtraction{Revenue} - {Cost}
MULTIPLY×Multiplication{Unit Price} * {Quantity}
DIVIDE÷Division (fails on zero divisor){Total} / {Quantity}
PARENTHESES( )Parentheses control precedence({Field A} + {Field B}) * 2

TIP

Operators are displayed as symbols (+ - × ÷ ( )) in the formula helper; use parentheses to adjust evaluation order.

Math Functions (18) ​

FunctionDescriptionExample
SUMSum, supports column referencesSUM(1, 2, 3), SUM([Sales].[Amount])
AVGAverage, supports column referencesAVG({Chinese}, {Math})
MAX / MINMaximum / minimum, supports column referencesMAX({Value1}, {Value2})
ROUNDRoundROUND({Value}, 2)
CEILING / FLOORRound up / downCEILING({Value})
ABSAbsolute valueABS({Value})
MODModuloMOD(17, 5)
POWERPowerPOWER(2, 10)
SQRTSquare rootSQRT(16)
LN / LOG / EXPLogarithm and exponentialLN({Value})
PI / EConstantsPI()
RAND / RANDBETWEENRandom numbersRANDBETWEEN(1, 10)

Text Functions (14) ​

FunctionDescriptionExample
CONCATConcatenateCONCAT({First}, {Last})
LEFT / RIGHT / MIDSubstringLEFT({Text}, 3)
LENLengthLEN({Text})
UPPER / LOWERCase conversionUPPER({Text})
TRIMTrim spacesTRIM({Text})
SUBSTITUTE / REPLACEReplaceSUBSTITUTE({Text}, "old", "new")
FINDFind substringFIND("keyword", {Text})
REPTRepeat textREPT("★", {Rating})
TEXTFormat as textTEXT({Value}, "0.00")
VALUEText to numberVALUE({Text})

Date Functions (15) ​

FunctionDescriptionExample
TODAY / NOWCurrent date / datetimeTODAY()
YEAR / MONTH / DAYExtract year/month/dayYEAR({Date})
HOUR / MINUTE / SECONDExtract time partsHOUR({DateTime})
WEEKDAYDay of weekWEEKDAY({Date})
DATEADDAdd to dateDATEADD({Date}, 3, "days")
DATEDIF / DATEDIFFDate differenceDATEDIFF({End}, {Start}, "days")
DATETIME_FORMATFormat datetimeDATETIME_FORMAT({Date}, "YYYY-MM-DD")
FROMUNIXTIME / UNIXTIMESTAMPUnix timestamp conversionsUNIXTIMESTAMP({Date})

Logic Functions (16) ​

FunctionDescriptionExample
IFConditionalIF({Status}="Done", 100, 0)
IFS / SWITCHMulti-branchSWITCH({Level}, "A", 90, "B", 80, 0)
AND / OR / XORLogical combinationAND({Cond1}, {Cond2})
NOTNegationNOT({Cond})
IFERRORCatch error, return fallbackIFERROR({a}/{b}, 0)
ISBLANK / ISERROR / ISNUMBER / ISTEXT / ISDATEType checksISBLANK({Field})
BLANK / NA / ERRORSpecial valuesBLANK()

Statistical Functions (13) ​

FILTER / COUNTIF / SUMIF / AVERAGEIF support cross-table conditional aggregation combined with column references and CurrentValue:

FunctionDescriptionExample
COUNTNumeric count, supports column referencesCOUNT([Sales].[Amount])
COUNTANon-empty count, supports column referencesCOUNTA([Sales].[Amount])
COUNTBLANKEmpty countCOUNTBLANK({Field1}, {Field2})
COUNTIFConditional countCOUNTIF([Sales].[City], "Beijing")
SUMIFConditional sumSUMIF([Sales].[City], CurrentValue = "Beijing", [Sales].[Amount])
AVERAGEIFConditional averageAVERAGEIF([Sales].[Amount], CurrentValue > 100)
FILTERConditional filter (returns array, usually nested with SUM/COUNT)SUM(FILTER([Sales].[Amount], CurrentValue > 100))
STDEV / VARStandard deviation / varianceSTDEV([Sales].[Amount])
MEDIAN / MODEMedian / modeMEDIAN([Sales].[Amount])
RANKRankingRANK({Score}, [Exam].[Score])
UNIQUEDeduplicateUNIQUE([Sales].[City])

Cross-Table References and Conditional Aggregation ​

Combining [Table].[Field] column references, CurrentValue traversal and statistical functions, formula fields can perform report-style cross-table calculations. The following examples use two tables:

  • Sales with fields City (text), Amount (number), Status (single select: Completed / In Progress)
CityAmountStatus
Beijing100Completed
Shanghai200In Progress
Beijing300Completed
Guangzhou400Completed
  • Summary holding the cross-table formula fields.

Example 1: Cross-Table Sum ​

SUM([Sales].[Amount])

Sums the entire Amount column. Expected result: 1000.

Example 2: Conditional Count (String Criteria) ​

COUNTIF([Sales].[City], "Beijing")

Counts rows whose City equals "Beijing". Expected result: 2.

Example 3: Conditional Sum (CurrentValue Criteria) ​

SUMIF([Sales].[City], CurrentValue = "Beijing", [Sales].[Amount])

Visits the City column; when CurrentValue (the current city) equals "Beijing", the corresponding Amount is added. Expected result: 400 (100 + 300).

Example 4: FILTER Then Aggregate ​

SUM(FILTER([Sales].[Amount], CurrentValue > 150))

FILTER first picks values greater than 150 ([200, 300, 400]), then SUM adds them up. Expected result: 900.

Example 5: Multi-Condition Aggregation ​

SUM(FILTER([Sales].[Amount], AND(CurrentValue > 100, CurrentValue < 400)))

Sums values greater than 100 and less than 400. Expected result: 500 (200 + 300).

Capability Boundary

Multi-condition aggregation currently supports multiple CurrentValue conditions on the same column only (as above). Referencing another column inside a FILTER condition for row-by-row matching (e.g. "Amount > 100 AND Status = Completed") is not supported yet. SUMIFS / COUNTIFS are also not supported — use FILTER + AND instead.

Example 6: Conditional Average and Text Concatenation ​

AVERAGEIF([Sales].[Amount], CurrentValue >= 200)
CONCAT("Beijing deals: ", COUNTIF([Sales].[City], "Beijing"), " orders")

The first formula averages amounts ≥ 200 (expected result: 300); the second outputs Beijing deals: 2 orders.

Example 7: Mixing Row-Level and Column References ​

{Quantity} * {Unit Price} + SUM([Sales].[Amount])

Row-level calculation and cross-table aggregation combine freely: the current row's quantity times unit price, plus the entire Amount column of the Sales table.

Referencing Lookup Fields ​

Formulas can reference lookup fields via row-level {Field Name} syntax: the server computes the lookup field's result first, then evaluates the formula, keeping the formula value consistent with the lookup field's display value.

Value Shapes ​

The value shape of a lookup field in a formula depends on its aggregation setting:

Lookup AggregationReturned ShapeBehavior in Formulas
SUM / COUNT / AVG / MAX / MIN and other aggregationsSingle value (may be a text-form number, e.g. "3.5")Automatically converted to a number in arithmetic operations
Original valuesArray (values of multiple linked source records)Not suitable for direct arithmetic; aggregate first with SUM / MAX, etc.

Converting with VALUE ​

When a lookup field returns a text-form number, it is recommended to convert it explicitly with the VALUE function for clearer semantics and more stable results across the frontend and backend:

{Estimated Hours} - VALUE({Project Progress})

VALUE strips currency symbols (¥, $, etc.) and thousand separators before converting to a number; text that cannot be converted returns a blank value.

Examples ​

  • Remaining hours: {Estimated Hours} - VALUE({Project Progress})
  • Scale a lookup result: VALUE({Customer Rating}) * 2

Syntax Tolerance

Function names are case-insensitive (value(...) equals VALUE(...)); accidentally typed full-width parentheses () and commas , are parsed as half-width automatically.

Difference from Column References

Lookup fields support row-level references ({Lookup Field Name}), but do not support column references ([Table].[Lookup Field] yields no values — evaluation degrades to 0 / blank).

Result Formatting ​

Formula fields support several result formats:

  • Number: decimal precision, thousand separators.
  • Currency: currency symbol (¥, $, etc.).
  • Percent: multiplies by 100 and appends %.
  • Date/DateTime: date display format.

TIP

Formats can be changed after saving. If the formula returns a timestamp, choose a date format to avoid displaying a long number.

Basic Examples ​

Total Price ​

{Quantity} * {Unit Price}

Completion Rate ​

IF({Total} > 0, {Completed} / {Total} * 100, 0)

Overdue Check ​

IF({Due Date} < TODAY(), "Overdue", "On Track")

Status Label ​

IF({Progress} = 100, "Done", IF({Progress} > 0, "In Progress", "Not Started"))

FAQ ​

Q: The cross-table reference always returns 0? A: Check: ① the referenced table must be in the same Base (cross-Base is not supported); ② table/field names must match the actual names (renames do not propagate into formulas); ③ the referenced column must not be a formula, lookup or link field; ④ refresh the page after fixing — formula values are recomputed by the server in real time.

Q: Referencing a lookup field in a formula fails or returns unexpected results? A: Row-level references ({Lookup Field}) are supported — the server computes the lookup result first, then evaluates the formula. If the lookup returns a text-form number (e.g. "3.5"), convert it explicitly with VALUE({Lookup Field}); when using "original values" mode (array result), aggregate first with SUM / MAX. Note that column references ([Table].[Lookup Field]) are not supported yet.

Q: The formula shows #ERROR? A: #ERROR means evaluation failed. Common causes: division by zero (use IFERROR({a}/{b}, 0)), misspelled function names, or wrong argument count/types. Hover over a function in the helper to see its correct syntax and examples.

Q: Are SUMIFS / COUNTIFS supported? A: Not yet. Use FILTER + AND instead, e.g. SUM(FILTER([Sales].[Amount], AND(CurrentValue > 100, CurrentValue < 400))).

Q: What is CurrentValue and where can it be used? A: It represents the current element while a condition function traverses a column. It is only allowed in the criteria argument of FILTER / COUNTIF / SUMIF / AVERAGEIF, e.g. COUNTIF([Sales].[Amount], CurrentValue > 100).

Q: Will the formula update when the referenced table changes? A: Yes. Cross-table formulas are computed in real time by the server when records are read. Refresh to see the latest results — no manual recalculation needed.

Q: Numbers stored as text (e.g. "1.3") — do they break calculations? A: No. Aggregation and numeric comparison automatically strip currency symbols (¥, $, etc.) and thousand separators, converting strings to numbers. Non-numeric text is skipped or treated as non-matching.

Debugging Tips ​

  1. Use editor validation: saving validates syntax, field references and column references, with error messages pinpointing problems (e.g. "unknown column reference").
  2. Start small: write the innermost expression first (e.g. [Sales].[Amount]), then wrap functions layer by layer (SUM(...) → SUM(FILTER(...))).
  3. Validate conditions with FILTER alone: when unsure about a condition, check FILTER([Sales].[Amount], CurrentValue > 100) first, then nest the aggregate.
  4. Watch for empty values: empty cells appear as nulls in a column; COUNT / SUM skip them automatically; use ISBLANK for explicit checks.
  5. Match result format to output: if a timestamp shows as a long number, switch the field format to Date; if a ratio shows as an integer, multiply by 100 and choose Percent.
  6. Avoid circular references: when referencing other formula fields, make sure the chain never loops back to itself.

Notes ​

  • Formula fields are read-only; results cannot be edited manually.
  • Results recalculate automatically when referenced field values change.
  • Formula fields can reference other formula fields, but avoid circular references.
  • The referenced table must be in the same Base as the current table.

Released under the MIT License.