$compute
The $compute query option adds computed properties to each entity in the response.
Syntax
GET /odata/Products?$compute=price mul 1.1 as taxedPriceMultiple computed properties are comma-separated:
GET /odata/Products?$compute=concat(firstName,' ',lastName) as fullName,price mul qty as totalEach expression follows the pattern: expression as alias.
Supported expressions
String functions
| Function | Example | Result |
|---|---|---|
concat(a, b) | concat(first,' ',last) | Concatenation |
tolower(expr) | tolower(name) | Lowercase |
toupper(expr) | toupper(code) | Uppercase |
Arithmetic
| Operator | Example | Result |
|---|---|---|
add | price add 5 | Addition |
sub | price sub discount | Subtraction |
mul | price mul quantity | Multiplication |
div | total div count | Division (returns null if divisor is 0) |
Date functions
| Function | Example | Result |
|---|---|---|
year(prop) | year(createdAt) | Year as integer |
month(prop) | month(createdAt) | Month as integer |
day(prop) | day(createdAt) | Day as integer |
Literals
| Type | Example |
|---|---|
| String | 'hello' |
| Integer | 42 |
| Float | 3.14 |
Property references
Any declared property name can be used directly:
price mul 1.1 as taxedEvaluation
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,taxedThis returns only name and the computed taxed property.