Skip to content

Formulas

Formulas are the power behind dynamic content in EmberBlocks. Use formulas to display calculated values, filter data, create conditional logic, and much more.

Formulas are SQL-like expressions that evaluate to dynamic values. They allow you to:

  • Display data from your tables
  • Perform calculations
  • Create conditional logic
  • Filter and aggregate data
  • Format values for display

Formulas use double curly braces {{}} to reference data:

{{table.field}} -- Reference a field from a table
{{$row.field}} -- Current row in list context
{{$row.price * $row.qty}} -- Arithmetic expression

Reference fields from any table in your app:

{{customers.name}}
{{orders.total}}
{{products.price}}

In list contexts (like a List component), use $row to reference the current row:

{{$row.name}}
{{$row.email}}
{{$row.created_at}}

Access related data through joins:

{{$row.customer.name}}
{{$row.order.items}}
OperatorDescriptionExample
+Addition{{$row.price + $row.tax}}
-Subtraction{{$row.total - $row.discount}}
*Multiplication{{$row.price * $row.quantity}}
/Division{{$row.total / $row.count}}
OperatorDescriptionExample
=Equal{{$row.status = 'active'}}
!=Not equal{{$row.type != 'draft'}}
<Less than{{$row.quantity < 10}}
>Greater than{{$row.price > 100}}
<=Less than or equal{{$row.stock <= 5}}
>=Greater than or equal{{$row.rating >= 4}}
OperatorDescriptionExample
ANDLogical AND{{$row.active AND $row.verified}}
ORLogical OR{{$row.admin OR $row.editor}}
NOTLogical NOT{{NOT $row.deleted}}

Returns different values based on a condition:

IF(condition, value_if_true, value_if_false)

Examples:

IF($row.status = 'active', 'Yes', 'No')
IF($row.quantity < 10, 'Low Stock', 'In Stock')
IF($row.price > 100, 'Premium', IF($row.price > 50, 'Standard', 'Budget'))

Returns the first non-null value:

COALESCE(value1, value2, ...)

Example:

COALESCE($row.nickname, $row.first_name, 'Unknown')

Checks if a value is null:

ISNULL($row.deleted_at) -- Returns true if deleted_at is null

Calculate values across multiple rows:

FunctionDescriptionExample
SUM()Total of valuesSUM(orders.total)
COUNT()Number of rowsCOUNT(orders.*)
AVG()Average valueAVG(products.price)
MIN()Minimum valueMIN(orders.date)
MAX()Maximum valueMAX(products.rating)
FunctionDescriptionExample
CONCAT()Join stringsCONCAT($row.first, ' ', $row.last)
UPPER()UppercaseUPPER($row.code)
LOWER()LowercaseLOWER($row.email)
TRIM()Remove whitespaceTRIM($row.name)
SUBSTRING()Extract portionSUBSTRING($row.code, 0, 3)
FunctionDescriptionExample
NOW()Current date/timeNOW()
TODAY()Current dateTODAY()
DATE_ADD()Add to dateDATE_ADD($row.due_date, 7, 'days')
DATE_DIFF()Difference between datesDATE_DIFF(NOW(), $row.created_at, 'days')
FORMAT_DATE()Format dateFORMAT_DATE($row.date, 'MMM DD, YYYY')
FunctionDescriptionExample
TEXT()Convert to textTEXT($row.quantity)
NUMBER()Convert to numberNUMBER($row.price_text)
DATE()Convert to dateDATE($row.date_string)

Filter rows from a table:

FILTER(table, condition)

Example:

FILTER(orders, orders.status = 'pending')
FILTER(products, products.price > 50)

Find a single row matching a condition:

LOOKUP(table, condition)
LOOKUP(table, condition).field

Example:

LOOKUP(users, users.id = $row.user_id).name
LOOKUP(settings, settings.key = 'currency').value

Formulas have access to context variables based on where they’re used:

The current row in a list context:

{{$row.id}}
{{$row.name}}
{{$row.created_at}}

The current authenticated user:

{{$user.id}}
{{$user.email}}
{{$user.display_name}}

If connected to an external user table, additional fields are available:

{{$user.department}}
{{$user.manager_id}}

Current app metadata:

{{$app.name}}
{{$app.id}}

In list contexts with selection enabled:

COUNT($selectedRows)
SUM($selectedRows.amount)

URL parameters passed to the view:

{{$params.id}}
{{$params.filter}}

Different formula locations have different available variables:

ContextAvailable Variables
Component visibilityAll tables, $user, $app
List filterAll tables, $user, $app
List field displayAll tables, $row, $user, $app
Text componentAll tables, $user, $app
Button disabledAll tables, $selectedRows, $user, $app
Action parametersAll tables, $row, $selectedRows, $user, $app
Default valueAll tables, $user, $app
Computed valueAll tables, $row, $user, $app

Formulas return different types depending on the expression:

TypeDescriptionExample
TextString value"Hello World"
NumberNumeric value42, 3.14
BooleanTrue/falsetrue, false
DateDate value2026-01-23
DateTimeDate and time2026-01-23T10:30:00
RecordSingle rowLOOKUP(users, ...)
ArrayList of values[1, 2, 3]
TableList of recordsFILTER(orders, ...)

The formula editor provides tools to help you write formulas:

  • Syntax highlighting - Color-coded syntax for readability
  • Auto-completion - Suggestions for tables, fields, and functions
  • Inline documentation - Tooltips with function descriptions
  • Validation - Real-time error checking
  • Test mode - Preview formula results with sample data
  1. Click any formula field to open the editor
  2. Type your formula or use auto-complete
  3. Check the preview to verify results
  4. Click Save to apply
CONCAT($row.first_name, ' ', $row.last_name)
{{$row.subtotal * (1 + $row.tax_rate)}}
IF($row.status = 'active', 'green', IF($row.status = 'pending', 'yellow', 'red'))
DATE_DIFF($row.due_date, TODAY(), 'days')
FILTER(tasks, tasks.assigned_to = $user.id)

Show a component only for admins:

$user.role = 'admin'
TODAY()
SUM(FILTER(transactions, transactions.date <= $row.date).amount)
  • Break complex logic into smaller pieces
  • Use intermediate computed fields when helpful
  • Comment complex formulas in the description
  • Filter data at the source when possible
  • Avoid deeply nested FILTER operations
  • Use indexed fields in LOOKUP conditions
  • Use COALESCE for potentially null values
  • Add ISNULL checks before operations
  • Provide meaningful default values
  • Test formulas with edge cases
  • Verify behavior with empty data
  • Check date formulas across time zones
ErrorCauseSolution
”Field not found”Typo in field nameCheck spelling and table reference
”Type mismatch”Wrong data typeUse type conversion functions
”Null reference”Accessing null valueAdd COALESCE or null check
”Syntax error”Invalid formula syntaxCheck parentheses and operators
  1. Test small parts of the formula first
  2. Use the formula preview with sample data
  3. Check that all referenced tables are available
  4. Verify field types match expected operations

Now that you understand formulas, explore: