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 ​

Computed properties are always part of the response, whatever $select names. $select accepts only declared properties, so list the declared ones you want and leave the alias out:

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

This returns name and the computed taxed property. Naming taxed in $select answers 400 with code unknown_property.