Skip to content

Expression

The value of the column: a column name, a relation path, a calculation or an aggregate, such as Customer.Name, Quantity * UnitPrice or Sum(Amount).

Type

string

Declaration

1
 string myQueryColumn.Expression

Remarks

An expression can contain:

  • column names and relation paths, such as Amount or Customer.Region.Name
  • aggregate functions: Count, CountDistinct, Sum, SumDistinct, Avg, AvgDistinct, Min, Max, StdDev, such as Sum(Amount)
  • date functions: Now(), DatePart(part, date), DateTrunc(part, date), DateDiff(part, from, to), where part is one of 'Year', 'Quarter', 'Month', 'Week', 'Day', 'Hour', 'Minute', 'Second'
  • integer constants, +, -, *, / and parentheses, such as Quantity * UnitPrice

Function names are case-insensitive. When an expression contains more than one - or / operator, use parentheses to make the evaluation order explicit.

Aggregate columns group the result by the other, non-aggregate columns.

Examples

Calculated and aggregate columns

1
2
3
4
5
6
var columns = [
    { Name : 'Customer', Expression : 'Customer.Name' },
    { Name : 'Month', Expression : "DateTrunc('Month', OrderDate)" },
    { Name : 'Total', Expression : 'Sum(Quantity * UnitPrice)' },
    { Name : 'Orders', Expression : 'CountDistinct(Id)' }
];