Skip to content

$compute

The $compute query option adds computed properties to each entity in the response.

Syntax

GET /odata/Products?$compute=price mul 1.1 as taxedPrice

Multiple computed properties are comma-separated:

GET /odata/Products?$compute=concat(firstName,' ',lastName) as fullName,price mul qty as total

Each expression follows the pattern: expression as alias.

Supported expressions

String functions

FunctionExampleResult
concat(a, b)concat(first,' ',last)Concatenation
tolower(expr)tolower(name)Lowercase
toupper(expr)toupper(code)Uppercase

Arithmetic

OperatorExampleResult
addprice add 5Addition
subprice sub discountSubtraction
mulprice mul quantityMultiplication
divtotal div countDivision (returns null if divisor is 0)

Date functions

FunctionExampleResult
year(prop)year(createdAt)Year as integer
month(prop)month(createdAt)Month as integer
day(prop)day(createdAt)Day as integer

Literals

TypeExample
String'hello'
Integer42
Float3.14

Property references

Any declared property name can be used directly:

price mul 1.1 as taxed

Evaluation

Computed properties are evaluated in PHP after the row is fetched from the database, not at the SQL level. When $compute is present, the resolver skips SQL-level $select so all columns are available for computation. The engine applies response-level projection afterward.

Interaction with $select

You can select computed properties:

GET /odata/Products?$compute=price mul 1.1 as taxed&$select=name,taxed

This returns only name and the computed taxed property.

OData: MIT | Core: BSL 1.1 | SDK: Commercial License