Criteria Language Syntax
- 24 minutes to read
The DevExpress Data Library features criteria language that you can use in various DevExpress products for building expressions. An expression is a string that, when parsed using the CriteriaOperator.Parse method to a CriteriaOperator object, evaluates a value. The table below contains constants, operators, and functions you can use in expressions.
Tip
You can use the LINQ-Like Criteria Syntax to create type-safe criteria expressions from lambda expressions.
The following DevExpress products extend and override this syntax. The table below lists the articles that explain how to use expressions in these products.
Product | Article |
---|---|
Reporting | Expression Constants, Operators, and Functions |
Dashboard | Expression Constants, Operators, and Functions |
Pivot Grid | Pivot Grid Expression Syntax |
EF Core and XPO ORM | Upcasting, Free Joins, How to: Filter Persistent Objects by Type |
XAF (Cross-Platform .NET App UI & Web API) | Function Criteria Operators |
Constants
Constant | Description | Example | XLS(x) Format Export-Friendly[1] |
---|---|---|---|
String constants | Wrap string constants in apostrophes. If a string contains an apostrophe, double the apostrophe. |
| Yes |
Char constants | Wrap char constants in apostrophes and add the suffix c. |
| Yes |
Date-time constants | Wrap date-time constants in ‘#’. |
| Yes |
DateOnly/TimeOnly constants | Wrap DateOnly and TimeOnly constants in ‘#’ and ‘!’. |
| - |
True | The Boolean |
| Yes |
False | The Boolean |
| Yes |
Enumeration | Specify an enumeration value using its underlying integer value. |
Note that you cannot specify an enumeration value using its qualified name. The following criteria is incorrect:
You can register custom enumerations using static methods of the EnumProcessingHelper class and then refer to enumeration values as follows:
| Yes |
Guid | Wrap a Guid constant in curly braces. Use Guid constants in a relational operation with equality or inequality operators only. |
| Yes |
Numeric | Specify different numeric constant types in a string form using suffixes:
|
| Yes |
null | Represents a null reference that does not refer to any object. To compare an operand with |
| Yes |
You can build parameterized criteria using any number of positional parameters. To do this, add parameter placeholders (question mark characters) to a criteria expression to identify parameter positions and provide a list of parameter values. When building criteria, parameter placeholders are substituted with parameter values in values in the order they are listed.
CriteriaOperator.Parse("[Name] == ? and [Age] == ?", "John", 33)
The following two examples are identical, but the second one reduces chances of formatting errors.
CriteriaOperator.Parse("[OrderDate] >= #1/1/2009#")
CriteriaOperator.Parse("[OrderDate] >= ?", new DateTime(2009, 1, 1))
When parameters are not specified, a parameter placeholder is substituted with null.
CriteriaOperator.Parse("[Region] != ?")
Important
For security reasons, do not use values entered by a user in criteria expressions without additional formatting. Refer to the FormatConstantValue(Object) static method description for details.
Operators
Operator | Description | Example | XLS(x) Format Export-Friendly[1] |
---|---|---|---|
| Adds the value of one numeric expression to another (to concatenate string values, use the Concat function). |
| Yes |
| Finds the difference between two numbers. |
| Yes |
| Multiplies the value of two expressions. |
| Yes |
| Divides the first operand by the second. |
| Yes |
| Returns the remainder (modulus) obtained by dividing one numeric expression by another. |
| Yes |
| Performs a bitwise inclusive OR on two numeric expressions. Compares each bit of its first operand to the corresponding bit of its second operand. If either bit is 1, the corresponding resulting bit is set to 1. Otherwise, the corresponding resulting bit is set to 0. |
| Yes |
| The bitwise AND operator. Compares each bit of its first operand to the corresponding bit of its second operand. If both bits are 1, the corresponding resulting bit is set to 1. Otherwise, the corresponding resulting bit is set to 0. |
| Yes |
| Performs a bitwise exclusive OR on two numeric expressions. |
| Yes |
| Returns |
| Yes |
!= | Returns |
| Yes |
| Less than operator. Used to compare expressions. |
| Yes |
| Less than or equal to operator. Used to compare expressions. |
| Yes |
| Greater than or equal to operator. Used to compare expressions. |
| Yes |
| Greater than operator. Used to compare expressions. |
| Yes |
| Tests for the existence of a property in an object. |
| - |
| Specifies a range to test. Returns |
| Yes |
| Performs a logical conjunction on two Boolean expressions. |
| Yes |
| Performs a logical disjunction on two Boolean expressions. |
| Yes |
| Performs a bitwise negation on a numeric expression. |
| - |
| Performs a logical negation on a Boolean expression. |
| Yes |
| Returns a numeric expression’s value (a unary operator). |
| Yes |
| Returns the negative of a numeric expression’s value (a unary operator). |
| Yes |
| Returns |
| Yes |
| Returns |
| Yes |
| Returns |
| No |
| Returns |
| No |
Functions
Aggregate Functions
Function | Description | Example | XLS(x) Format Export-Friendly[1] |
---|---|---|---|
| Evaluates the average of the values in the collection. |
| - |
| Returns the number of objects in a collection. |
| - |
| Determines whether the object exists in the collection. |
| - |
| Returns the maximum expression value in a collection. |
| - |
| Returns the minimum expression value in a collection. |
| - |
| Returns a single object from a collection that contains no more than one object. If the collection contains more objects, use the Condition property to specify a condition. The collection must contain only one object that satisfies the condition; otherwise, the function’s behavior is undefined (the function may return an unexpected value or throw an exception). You can pass an expression as a parameter: The function returns the |
| - |
| Returns the sum of all the expression values in the collection. |
| - |
| Returns True if |
| - |
A custom aggregate function | Returns a custom expression value for a collection, according to a custom aggregate function. You can call the function directly or pass it as a parameter. | - |
Date-time Functions
Function | Description | Example | XLS(x) Format Export-Friendly[1] |
---|---|---|---|
AddDays(DateTime, DaysCount) | Returns a date-time value that is the specified number of days from the specified DateTime. | AddDays([OrderDate], 30) |
Yes |
AddHours(DateTime, HoursCount) | Returns a date-time value that is the specified number of hours from the specified DateTime. | AddHours([StartTime], 2) |
Yes |
AddMilliSeconds(DateTime, MilliSecondsCount) | Returns a date-time value that is the specified number of milliseconds from the specified DateTime. | AddMilliSeconds(([StartTime], 5000)) |
- |
AddMinutes(DateTime, MinutesCount) | Returns a date-time value that is the specified number of minutes from the specified DateTime. | AddMinutes([StartTime], 30) |
Yes |
AddMonths(DateTime, MonthsCount) | Returns a date-time value that is the specified number of months from the specified DateTime. | AddMonths([OrderDate], 1) |
Yes |
AddSeconds(DateTime, SecondsCount) | Returns a date-time value that is the specified number of seconds from the specified DateTime. | AddSeconds([StartTime], 60) |
Yes |
AddTicks(DateTime, TicksCount) | Returns a date-time value that is the specified number of ticks from the specified DateTime. | AddTicks([StartTime], 5000) |
- |
AddTimeSpan(DateTime, TimeSpan) | Returns a date-time value that is from the specified DateTime for the given TimeSpan. | AddTimeSpan([StartTime], [Duration]) |
- |
AddYears(DateTime, YearsCount) | Returns a date-time value that is the specified number of years from the specified DateTime. | AddYears([EndDate], -1) |
Yes |
DateDiffDay(startDate, endDate) | The differences in days between the two specified dates (time portion is not taken into account). | DateDiffDay([StartTime], Now()) |
Yes |
DateDiffHour(startDate, endDate) | The difference in hours between the two specified dates (minutes are not taken into account). | DateDiffHour([StartTime], Now()) |
Yes |
DateDiffMilliSecond(startDate, endDate) | Returns the number of millisecond boundaries between two non-nullable dates. | DateDiffMilliSecond([StartTime], Now()) |
- |
DateDiffMinute(startDate, endDate) | Returns the number of minute boundaries between two non-nullable dates. | DateDiffMinute([StartTime], Now()) |
Yes |
DateDiffMonth(startDate, endDate) | Returns the number of month boundaries between two non-nullable dates. | DateDiffMonth([StartTime], Now()) |
Yes |
DateDiffSecond(startDate, endDate) | Returns the number of second boundaries between two non-nullable dates. | DateDiffSecond([StartTime], Now()) |
Yes |
DateDiffTick(startDate, endDate) | Returns the number of tick boundaries between two non-nullable dates. | DateDiffTick([StartTime], Now()) |
- |
DateDiffYear(startDate, endDate) | Returns the number of year boundaries between two non-nullable dates. | DateDiffYear([StartTime], Now()) |
Yes |
GetDate(DateTime) | Extracts a date from the defined DateTime. The return value represents a DateTime object with the same date part, and the time part set to 00:00:00 . |
GetDate([OrderDateTime]) |
Yes |
GetDay(DateTime) | Extracts a day from the defined DateTime. | GetDay([OrderDate]) |
Yes |
GetDayOfWeek(DateTime) | Extracts a day of the week from the defined DateTime. | GetDayOfWeek([OrderDate]) |
Yes |
GetDayOfYear(DateTime) | Extracts a day of the year from the defined DateTime. | GetDayOfYear([OrderDate]) |
Yes |
GetHour(DateTime) | Extracts an hour from the defined DateTime. | GetHour([StartTime]) |
Yes |
GetMilliSecond(DateTime) | Extracts milliseconds from the defined DateTime. | GetMilliSecond([StartTime]) |
- |
GetMinute(DateTime) | Extracts minutes from the defined DateTime. | GetMinute([StartTime]) |
Yes |
GetMonth(DateTime) | Extracts a month from the defined DateTime. | GetMonth([StartTime]) |
Yes |
GetSecond(DateTime) | Extracts seconds from the defined DateTime. | GetSecond([StartTime]) |
Yes |
GetTimeOfDay(DateTime) | Extracts the time of the day from the defined DateTime in ticks. | GetTimeOfDay([StartTime]) |
- |
GetYear(DateTime) | Extracts a year from the defined DateTime. | GetYear([StartTime]) |
Yes |
IsApril(DateTime) | Returns True if the specified date falls within April. | IsApril([OrderDate]) |
Yes |
IsAugust(DateTime) | Returns True if the specified date falls within August. | IsAugust([OrderDate]) |
Yes |
IsDecember(DateTime) | Returns True if the specified date falls within December. | IsDecember([OrderDate]) |
Yes |
IsFebruary(DateTime) | Returns True if the specified date falls within February. | IsFebruary([OrderDate]) |
Yes |
IsJanuary(DateTime) | Returns True if the specified date falls within January. | IsJanuary([OrderDate]) |
Yes |
IsJuly(DateTime) | Returns True if the specified date falls within July. | IsJuly([OrderDate]) |
Yes |
IsJune(DateTime) | Returns True if the specified date falls within June. | IsJune([OrderDate]) |
Yes |
IsLastMonth(DateTime) | Returns True if the specified date falls within the previous month. | IsLastMonth([OrderDate]) |
Yes |
IsLastYear(DateTime) | Returns True if the specified date falls within the previous year. | IsLastYear([OrderDate]) |
Yes |
IsMarch(DateTime) | Returns True if the specified date falls within March. | IsMarch([OrderDate]) |
Yes |
IsMay(DateTime) | Returns True if the specified date falls within May. | IsMay([OrderDate]) |
Yes |
IsNextMonth(DateTime) | Returns True if the specified date falls within the next month. | IsNextMonth([OrderDate]) |
Yes |
IsNextYear(DateTime) | Returns True if the specified date falls within the next year. | IsNextYear([OrderDate]) |
Yes |
IsNovember(DateTime) | Returns True if the specified date falls within November. | IsNovember([OrderDate]) |
Yes |
IsOctober(DateTime) | Returns True if the specified date falls within October. | IsOctober([OrderDate]) |
Yes |
IsSameDay(firstDate, secondDate, …) | Returns True if the specified date/time values fall within the same day. | IsSameDay([OrderDate], [ShipDate]) |
Yes |
IsSeptember(DateTime) | Returns True if the specified date falls within September. | IsSeptember([OrderDate]) |
Yes |
IsThisMonth(DateTime) | Returns True if the specified date falls within the current month. | IsThisMonth([OrderDate]) |
Yes |
IsThisWeek(DateTime) | Returns True if the specified date falls within the current week. | IsThisWeek([OrderDate]) |
Yes |
IsYearToDate(DateTime) | Returns True if the specified date falls within the year-to-date period. This period starts from the first day of the current year and continues to the current date (including the current date). | IsYearToDate([OrderDate]) |
Yes |
IsThisYear(DateTime) | Returns True if the specified date falls within the current year. | IsThisYear([OrderDate]) |
Yes |
InDateRange(Date, FromDate, ToDate) | Returns True if Date is more than or equal to FromDate , and less than the day that follows ToDate . The InDateRange(dateValue, from, to) filter is equivalent to the GetDate(from) <= dateValue && dateValue < AddDays(GetDate(to), 1) expression |
InDateRange([OrderDate], #2022-01-01#, #2022-12-31#) |
Yes |
LocalDateTimeDayAfterTomorrow() | Returns a date-time value corresponding to the day after Tomorrow. | AddDays(LocalDateTimeDayAfterTomorrow(), 5) |
Yes |
LocalDateTimeLastMonth() | Returns the DateTime value corresponding to the first day of the previous month. | AddMonths(LocalDateTimeLastMonth(), 5) |
Yes |
LocalDateTimeLastWeek() | Returns a date-time value corresponding to the first day of the previous week. | AddDays(LocalDateTimeLastWeek(), 5) |
Yes |
LocalDateTimeLastYear() | Returns the DateTime value corresponding to the first day of the previous year. | AddYears(LocalDateTimeLastYear(), 5) |
Yes |
LocalDateTimeNextMonth() | Returns a date-time value corresponding to the first day of the next month. | AddMonths(LocalDateTimeNextMonth(), 5) |
Yes |
LocalDateTimeNextWeek() | Returns a date-time value corresponding to the first day of the following week. | AddDays(LocalDateTimeNextWeek(), 5) |
Yes |
LocalDateTimeNextYear() | Returns a date-time value corresponding to the first day of the following year. | AddYears(LocalDateTimeNextYear(), 5) |
Yes |
LocalDateTimeNow() | Returns a date-time value corresponding to the current moment in time. | AddDays(LocalDateTimeNow(), 5) |
Yes |
LocalDateTimeThisMonth() | Returns a date-time value corresponding to the first day of the current month. | AddMonths(LocalDateTimeThisMonth(), 5) |
Yes |
LocalDateTimeThisWeek() | Returns a date-time value corresponding to the first day of the current week. | AddDays(LocalDateTimeThisWeek(), 5) |
Yes |
LocalDateTimeThisYear() | Returns a date-time value corresponding to the first day of the current year. | AddYears(LocalDateTimeThisYear(), 5) |
Yes |
LocalDateTimeToday() | Returns a date-time value corresponding to Today. | AddDays(LocalDateTimeToday(), 5) |
Yes |
LocalDateTimeTomorrow() | Returns a date-time value corresponding to Tomorrow. | AddDays(LocalDateTimeTomorrow(), 5) |
Yes |
LocalDateTimeTwoMonthsAway() | Returns the DateTime value corresponding to the first day of the following month. | AddMonths(LocalDateTimeTwoMonthAway(), 5) |
Yes |
LocalDateTimeTwoWeeksAway() | Returns the DateTime value corresponding to the first day of the following week. | AddDays(LocalDateTimeTwoWeeksAway(), 5) |
Yes |
LocalDateTimeTwoYearsAway() | Returns the DateTime value corresponding to the first day of the following year. | AddYears(LocalDateTimeTwoYearsAway(), 5) |
Yes |
LocalDateTimeYearBeforeToday() | Returns the DateTime value corresponding to the day one year ago. | AddYears(LocalDateTimeYearBeforeToday(), 5) |
Yes |
LocalDateTimeYesterday() | Returns a date-time value corresponding to Yesterday. | AddDays(LocalDateTimeYesterday(), 5) |
Yes |
Now() | Returns the current system date and time. | AddDays(Now(), 5) |
Yes |
Today() | Returns the current date. Regardless of the actual time, this function returns midnight of the current date. | AddMonths(Today(), 1) |
Yes |
UtcNow() | Returns the current system date and time, expressed as Coordinated Universal Time (UTC). | AddDays(UtcNow(), 7) |
- |
DateTimeFromParts(year, month, day, hour, minute, second, millisecond) | Returns a DateTime value constructed from the specified Year, Month, Day (Hour, Minute, Second, Millisecond optionally). | DateTimeFromParts(2020, 06, 25, 13, 40) |
- |
DateOnly Functions
Function | Description | Example | XLS(x) Format Export-Friendly[1] |
---|---|---|---|
AddDays(DateOnly, DaysCount) | Returns a date value that is the specified number of days from the specified DateOnly. | AddDays([OrderDate], 30) |
- |
AddMonths(DateOnly, MonthsCount) | Returns a date value that is the specified number of months from the specified DateOnly. | AddMonths([OrderDate], 1) |
- |
AddYears(DateOnly, YearsCount) | Returns a date value that is the specified number of years from the specified DateOnly. | AddYears([EndDate], -1) |
- |
DateDiffDay(startDate, endDate) | The differences in days between the two specified dates. | DateDiffDay([StartDate], Now()) |
- |
DateDiffMonth(startDate, endDate) | Returns the number of month boundaries between two non-nullable dates. | DateDiffMonth([StartDate], Now()) |
- |
DateDiffYear(startDate, endDate) | Returns the number of year boundaries between two non-nullable dates. | DateDiffYear([StartDate], Now()) |
- |
GetDay(DateOnly) | Extracts a day from the defined DateOnly. | GetDay([OrderDate]) |
- |
GetDayOfWeek(DateOnly) | Extracts a day of the week from the defined DateOnly. | GetDayOfWeek([OrderDate]) |
- |
GetDayOfYear(DateOnly) | Extracts a day of the year from the defined DateOnly. | GetDayOfYear([OrderDate]) |
- |
GetMonth(DateOnly) | Extracts a month from the defined DateOnly. | GetMonth([StartDate]) |
- |
GetYear(DateOnly) | Extracts a year from the defined DateOnly. | GetYear([StartDate]) |
- |
IsApril(DateOnly) | Returns True if the specified date falls within April. | IsApril([OrderDate]) |
- |
IsAugust(DateOnly) | Returns True if the specified date falls within August. | IsAugust([OrderDate]) |
- |
IsDecember(DateOnly) | Returns True if the specified date falls within December. | IsDecember([OrderDate]) |
- |
IsFebruary(DateOnly) | Returns True if the specified date falls within February. | IsFebruary([OrderDate]) |
- |
IsJanuary(DateOnly) | Returns True if the specified date falls within January. | IsJanuary([OrderDate]) |
- |
IsJuly(DateOnly) | Returns True if the specified date falls within July. | IsJuly([OrderDate]) |
- |
IsJune(DateOnly) | Returns True if the specified date falls within June. | IsJune([OrderDate]) |
- |
IsLastMonth(DateOnly) | Returns True if the specified date falls within the previous month. | IsLastMonth([OrderDate]) |
- |
IsLastYear(DateOnly) | Returns True if the specified date falls within the previous year. | IsLastYear([OrderDate]) |
- |
IsMarch(DateOnly) | Returns True if the specified date falls within March. | IsMarch([OrderDate]) |
- |
IsMay(DateOnly) | Returns True if the specified date falls within May. | IsMay([OrderDate]) |
- |
IsNextMonth(DateOnly) | Returns True if the specified date falls within the next month. | IsNextMonth([OrderDate]) |
- |
IsNextYear(DateOnly) | Returns True if the specified date falls within the next year. | IsNextYear([OrderDate]) |
- |
IsNovember(DateOnly) | Returns True if the specified date falls within November. | IsNovember([OrderDate]) |
- |
IsOctober(DateOnly) | Returns True if the specified date falls within October. | IsOctober([OrderDate]) |
- |
IsSameDay(firstDate, secondDate, …) | Returns True if the specified DateOnly values fall within the same day. | IsSameDay([OrderDate], [ShipDate]) |
- |
IsSeptember(DateOnly) | Returns True if the specified date falls within September. | IsSeptember([OrderDate]) |
- |
IsThisMonth(DateOnly) | Returns True if the specified date falls within the current month. | IsThisMonth([OrderDate]) |
- |
IsThisWeek(DateOnly) | Returns True if the specified date falls within the current week. | IsThisWeek([OrderDate]) |
- |
IsYearToDate(DateOnly) | Returns True if the specified date falls within the year-to-date period. This period starts from the first day of the current year and continues to the current date (including the current date). | IsYearToDate([OrderDate]) |
- |
IsThisYear(DateOnly) | Returns True if the specified date falls within the current year. | IsThisYear([OrderDate]) |
- |
InDateRange(date, fromDate, toDate) | Returns True if Date is more than or equal to FromDate , and less than the day that follows ToDate . The InDateRange(dateValue, from, to) filter is equivalent to the GetDate(from) <= dateValue && dateValue < AddDays(GetDate(to), 1) expression |
InDateRange([OrderDate], #!2022-01-01!#, #!2022-12-31!#) |
- |
DateOnlyFromParts(year, month, day) | Returns a DateOnly value constructed from the specified Year, Month, and Day. | DateOnlyFromParts(2020, 06, 25) |
- |
TimeOnly Functions
Function | Description | Example | XLS(x) Format Export-Friendly[1] |
---|---|---|---|
AddHours(TimeOnly, HoursCount) | Returns a time value that is the specified number of hours from the specified TimeOnly. | AddHours([StartTime], 2) |
- |
AddMilliSeconds(TimeOnly, MilliSecondsCount) | Returns a time value that is the specified number of milliseconds from the specified TimeOnly. This function is not supported in Entity Framework Core server mode sources. | AddMilliSeconds(([StartTime], 5000)) |
- |
AddMinutes(TimeOnly, MinutesCount) | Returns a time value that is the specified number of minutes from the specified TimeOnly. | AddMinutes([StartTime], 30) |
- |
AddSeconds(TimeOnly, SecondsCount) | Returns a time value that is the specified number of seconds from the specified TimeOnly. This function is not supported in Entity Framework Core server mode sources. | AddSeconds([StartTime], 60) |
- |
DateDiffHour(startTime, endTime) | The difference in hours between the two specified times (minutes are not taken into account). | DateDiffHour([StartTime], Now()) |
- |
DateDiffMilliSecond(startTime, endTime) | Returns the number of millisecond boundaries between two non-nullable times. | DateDiffMilliSecond([StartTime], Now()) |
- |
DateDiffMinute(startTime, endTime) | Returns the number of minute boundaries between two non-nullable times. | DateDiffMinute([StartTime], Now()) |
- |
DateDiffSecond(startTime, endTime) | Returns the number of second boundaries between two non-nullable times. | DateDiffSecond([StartTime], Now()) |
- |
GetHour(TimeOnly) | Extracts an hour from the defined TimeOnly. | GetHour([StartTime]) |
- |
GetMilliSecond(TimeOnly) | Extracts milliseconds from the defined TimeOnly. | GetMilliSecond([StartTime]) |
- |
GetMinute(TimeOnly) | Extracts minutes from the defined TimeOnly. | GetMinute([StartTime]) |
- |
GetSecond(TimeOnly) | Extracts seconds from the defined TimeOnly. | GetSecond([StartTime]) |
- |
Logical Functions
Function | Description | Example | XLS(x) Format Export-Friendly |
---|---|---|---|
| Returns one of several specified values depending upon the values of logical expressions. The function can take 2N+1 arguments, so you can write a multi-If statement (N – the number of specified logical expressions):
… |
| Yes |
| Returns True if the specified Value is NULL. |
| Yes |
| Returns Value1 if it is not set to NULL; otherwise, Value2 is returned. |
| - |
| Returns True if the specified String object is NULL or an empty string; otherwise, False is returned. |
| Yes |
Math Functions
Function | Description | Example | XLS(x) Format Export-Friendly[1] |
---|---|---|---|
Abs(Value) | Returns the given numeric expression’s absolute, positive value. | Abs(1 - [Discount]) |
Yes |
Acos(Value) | Returns a number’s arccosine (the angle in radians, whose cosine is the given float expression). | Acos([Value]) |
Yes |
Asin(Value) | Returns a number’s arcsine (the angle in radians, whose sine is the given float expression). | Asin([Value]) |
Yes |
Atn(Value) | Returns a number’s arctangent (the angle in radians, whose tangent is the given float expression). | Atn([Value]) |
Yes |
Atn2(Value1, Value2) | Returns the angle whose tangent is the quotient of two specified numbers in radians. | Atn2([Value1], [Value2]) |
Yes |
BigMul(Value1, Value2) | Returns an Int64 containing the full product of two specified 32-bit numbers. | BigMul([Amount], [Quantity]) |
- |
Ceiling(Value) | Returns the smallest integer that is greater than or equal to the numeric expression. | Ceiling([Value]) |
Yes |
Cos(Value) | Returns the angle’s cosine, in radians. | Cos([Value]) |
Yes |
Cosh(Value) | Returns the angle’s hyperbolic cosine, in radians. | Cosh([Value]) |
Yes |
Exp(Value) | Returns the float expression’s exponential value. | Exp([Value]) |
Yes |
Floor(Value) | Returns the largest integer less than or equal to the numeric expression. | Floor([Value]) |
Yes |
Log(Value) | Returns a specified number’s natural logarithm. | Log([Value]) |
Yes |
Log(Value, Base) | Returns the logarithm of a specified number in a specified Base. | Log([Value], 2) |
Yes |
Log10(Value) | Returns a specified number’s base 10 logarithm. | Log10([Value]) |
Yes |
Max(Value1, Value2) | Returns the maximum value from the specified values. | Max([Value1], [Value2]) |
Yes |
Min(Value1, Value2) | Returns the minimum value from the specified values. | Min([Value1], [Value2]) |
Yes |
Power(Value, Power) | Returns a specified number raised to a specified power. | Power([Value], 3) |
Yes |
Rnd() | Returns a random number that is less than 1, but greater than or equal to zero. | Rnd()*100 |
Yes |
Round(Value) | Rounds the given value to the nearest integer. | Round([Value]) |
Yes |
Round(Value, Precision) | Rounds the given value to the nearest integer, or to a specified number of decimal places. | Round([Value], 2) |
Yes |
Sign(Value) | Returns the positive (+1), zero (0), or negative (-1) sign of the given expression. | Sign([Value]) |
Yes |
Sin(Value) | Returns the sine of the angle defined in radians. | Sin([Value]) |
Yes |
Sinh(Value) | Returns the hyperbolic sine of the angle defined in radians. | Sinh([Value]) |
Yes |
Sqr(Value) | Returns the square root of a given number. | Sqr([Value]) |
- |
Tan(Value) | Returns the tangent of the angle defined in radians. | Tan([Value]) |
Yes |
Tanh(Value) | Returns the hyperbolic tangent of the angle defined in radians. | Tanh([Value]) |
Yes |
ToDecimal(Value) | Converts Value to an equivalent decimal number. | ToDecimal([Value]) |
- |
ToDouble(Value) | Converts Value to an equivalent 64-bit double-precision floating-point number. | ToDouble([Value]) |
- |
ToFloat(Value) | Converts Value to an equivalent 32-bit single-precision floating-point number. | ToFloat([Value]) |
- |
ToInt(Value) | Converts Value to an equivalent 32-bit signed integer. | ToInt([Value]) |
- |
ToLong(Value) | Converts Value to an equivalent 64-bit signed integer. | ToLong([Value]) |
- |
String Functions
Function | Description | Example | XLS(x) Format Export-Friendly[1] |
---|---|---|---|
Ascii(String) | Returns the ASCII code value of the leftmost character in a character expression. | Ascii('a') |
- |
Char(Number) | Converts an integerASCIICode to a character. | Char(65) + Char(51) |
Yes |
CharIndex(String1, String2) | Returns the starting position of String1 within String2, beginning from the zero character position to the end of a string. | CharIndex('e', 'devexpress') |
- |
CharIndex(String1, String2, StartLocation) | Returns the starting position of String1 within String2, beginning from the StartLocation character position to the end of a string. | CharIndex('e', 'devexpress', 2) |
- |
Concat(String1, … , StringN) | Returns a string value containing the concatenation of the current string with any additional strings. | Concat('A', ')', [ProductName]) |
Yes |
Contains(String1, SubString1) | Returns True if SubString1 occurs within String1; otherwise, False is returned. | Contains([ProductName], 'dairy') |
Yes |
EndsWith(String1, SubString1) | Returns True if the end of String1 matches SubString1; otherwise, False is returned. | EndsWith([Description], 'The end.') |
Yes |
Insert(String1, StartPosition, String2) | Inserts String2 into String1 at the position specified by StartPositon | Insert([Name], 0, 'ABC-') |
- |
Len(Value) | Returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable. | Len([Description]) |
Yes |
Lower(String) | Returns String in lowercase. | Lower([ProductName]) |
Yes |
PadLeft(String, Length) | Left-aligns the defined string’s characters, padding its left side with white space characters up to a specified total length. | PadLeft([Name], 30) |
- |
PadLeft(String, Length, Char) | Left-aligns the defined string’s characters, padding its left side with the specified Char up to a specified total length. | PadLeft([Name], 30, '<') |
- |
PadRight(String, Length) | Right-aligns the defined string’s characters, padding its left side with empty space characters up to a specified total length. | PadRight([Name], 30) |
- |
PadRight(String, Length, Char) | Right-aligns the defined string’s characters, padding its left side with the specified Char up to a specified total length. | PadRight([Name], 30, '>') |
- |
Remove(String, StartPosition) | Deletes all the characters from this instance, beginning at a specified position. | Remove([Name], 3) |
- |
Remove(String, StartPosition, Length) | Deletes a specified number of characters from this instance, beginning at a specified position. | Remove([Name], 0, 3) |
- |
Replace(String1, SubString2, String3) | Returns a copy of String1, in which SubString2 has been replaced with String3. | Replace([Name], 'The ', '') |
- |
Reverse(String) | Reverses the order of elements within String. | Reverse([Name]) |
- |
StartsWith(String1, SubString1) | Returns True if the beginning of String1 matches SubString1; otherwise, False. | StartsWith([Title], 'The best') |
Yes |
Substring(String, StartPosition, Length) | Retrieves a substring from String. The substring starts at StartPosition and has a specified Length. | Substring([Description], 2, 3) |
- |
Substring(String, StartPosition) | Retrieves a substring from String. The substring starts at StartPosition. | Substring([Description], 2) |
- |
ToStr(Value) | Returns a string representation of a specified value or property. | ToStr([ID]) |
- |
Trim(String) | Removes all leading and trailing SPACE characters from String. | Trim([ProductName]) |
Yes |
Upper(String) | Returns String in uppercase. | Upper([ProductName]) |
Yes |
Note
You can find a complete set of available function operators in the FunctionOperatorType enumeration description.
Collection Elements Verification
Use brackets []
to check if a collection contains an element that satisfies a condition. The following expression returns true
if the Accounts collection contains at least one element that satisfies the [Amount] == 100
condition:
[Accounts][[Amount] == 100]
The following expression returns false
if the Accounts collection is empty:
[Accounts][]
Parent Relating Operator
Use the parent relating operator (^
character) to refer to a parent in expressions written in the context of a child. You can apply this operator successively to navigate multiple parent relationships. In the expression below, the “RegistrationDate” field refers to a Customer (Orders’ parent) and the “Date” field refers to Orders. This expression returns true
if there is at least one Order that is made on the day the parent Customer is registered:
"[Orders][[^.RegistrationDate] == Date]"
Grouping Clauses with Brackets
It is important to use brackets to ensure that your expression returns the intended results.
For instance, the following expression for objects of the Customer type returns all the Customers where an Account exists with a Date of “8/25/2006” and where an account exists with an Amount of 100:
[Accounts][[Date] == #8/25/2006#] && [Accounts][[Amount] == 100]
Construct the expression as in the following example to search for all Customers that have an Account with both a Date of “8/25/2006” and an Amount of 100:
[Accounts][[Date] == #8/25/2006# && [Amount] == 100]
Operator Precedence
When an expression contains multiple operators, their precedence controls the order in which expression elements are evaluated.
- Literal values
- Parameters
- Identifiers
OR
(left-associative)AND
(left-associative).
relationship qualifier (left-associative)==
,!=
<
,>
,<=
,>=
-
,+
(left-associative)*
,/
,%
(left-associative)NOT
- unary
-
In
Iif
Trim()
,Len()
,Substring()
,IsNull()
[]
(for set-restriction)()
The default precedence can be changed by grouping elements with parentheses. For instance, the operators are performed in a default order in the first of the following two code samples. In the second code sample, the addition operation is performed first, because its associated elements are grouped with parentheses, and the multiplication operation is performed last.
Accounts[Amount == 2 + 48 * 2]
Accounts[Amount == (2 + 48) * 2]
Case Sensitivity
Operators are case insensitive. Although field values’ case sensitivity depends on the data source.
Note
A data source affects certain operators’ behavior. For instance, by default, the SQL Server Express 2005 is configured as case insensitive. In this case, the following expression always evaluates to true:
Lower(Name) == Upper(Name)
Field Names
You can mark a keyword-like field name with an escape character (@
sign). In the expression below, the CriteriaOperator.Parse method interprets @Or
as the field named “Or”, not the logical operator OR
.
@Or = 'value'
Tip
Use the FormatPropertyName(String) static method to format field names.
Usage Examples
The following help topic contains criteria examples: Build Criteria - Usage Examples.
-
The following restriction applies to DevExpress Data Grid and Tree List controls (WinForms and WPF) exported to XLS(X) in Data-Aware Export Mode:
Only expressions that contain export-friendly functions are exported to XLS(X) format. Refer to the XLS(x) Format Export-Friendly column in the tables above to find out if a function can be exported to XLS(X).
Ensure that the XlsExportOptionsEx.UnboundExpressionExportMode or XlsxExportOptionsEx.UnboundExpressionExportMode setting is set to AsFormula to export expressions for unbound columns.
See the following links to learn more: