Expression Constants, Operators, and Functions

The LoadGen Dashboards uses criteria language that you can use for building expressions. An expression is a string that evaluates some value. The criteria language is based on the the Cross-Platform Class Library with some additions and subtractions specific for dashboards.

The tables below contain constants, operators, and functions you can use in dashboard expressions.

Constants

Constant
Description
Example
String constants
Wrap string constants in apostrophes.
If a string contains an apostrophe, double the apostrophe.
[LoadBot] == ‘France’
[ApplicationName] == ‘Microsoft Word’
Date-time constants
Wrap date-time constants in ‘#’.
[ActualTime] >= #2021-03-22 13:18:51.94944#
True
Represents the Boolean True value.
[HasScreenshot] == True
False
Represents the Boolean False value.
[HasScreenshot] == False
Enumeration
Specify an enumeration value using its underlying integer value.
[Status] == 1
Note that you cannot specify an enumeration value using its qualified name. The following criteria is incorrect:
[Status] = Status.InProgress
Guid
Wrap a Guid constant in curly braces. Use Guid constants in a relational operation with equality or inequality operators only.
[ScheduleID] == {513724e5-17b7-4ec6-cbc4-0eae12c72c1f}
Numeric
Specify different numeric constant types in a string form using suffixes:
  • Int32 (int) - 1
  • Int16 (short) - 1s
  • Byte (byte) - 1b
  • Double (double) - 1.0
  • Single (float) - 1.0f
  • Decimal (decimal) - 1.0m
[MeasurementTime] == 1.025
?
Represents a null reference that does not refer to any object.
We recommend using the IsNull unary operator (for example, “[Region] is null”) or the IsNull logical function (for example, “IsNull([Region])”) instead.
[ApplicationName] != ?

Operators

Operator
Description
Example
+
Adds the value of one numeric expression to another or concatenates two strings.
[Iteration] + 4
[ApplicationName] + ‘-‘ + [MeasurementName]
-
Finds the difference between two numbers.
[MeasurementTime] - [ApplicationTime]
*
Multiplies the value of two expressions.
[Quantity] * [UnitPrice] * (1 - [BonusAmount])
/
Divides the first operand by the second.
[MeasurementTime] / 2
%
Returns the remainder (modulus) obtained by dividing one numeric expression by another.
[MeasurementTime] % 3
|
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.
[Flag1] | [Flag2]
&
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.
[Flag] & 10
^
Performs a bitwise exclusive OR on two numeric expressions.
[Flag1] ^ [Flag2]
==
=
Returns true if both operands have the same value; otherwise, it returns false.
[MeasurementTime] == 10
!=
Returns true if the operands do not have the same value; otherwise, it returns false.
[LoadBot] != ‘France’
<
Less than operator. Used to compare expressions.
[MeasurementTime] < 20
<=
Less than or equal to operator. Used to compare expressions.
[MeasurementTime] <= 20
>=
Greater than or equal to operator. Used to compare expressions.
[MeasurementTime] >= 30
>
Greater than operator. Used to compare expressions.
[MeasurementTime] > 30
In (,,,)
Tests for the existence of a property in an object.
[LoadBot] In (‘USA’, ‘UK’, ‘Italy’)
Between (,)
Specifies a range to test. Returns true if a value is greater than or equal to the first operand and less than or equal to the second operand.
[SessionTime] Between (10, 20)
And
&&
Performs a logical conjunction on two Boolean expressions.
[HasScreenshot] And ([MeasurementTime] > 5)
[HasScreenshot] && ([MeasurementTime]> 100)
Or
||


Performs a logical disjunction on two Boolean expressions.
[LoadBot]==’USA’ Or [LoadBot]==’UK’
[LoadBot]==’USA’ || [LoadBot]==’UK’
~
Performs a bitwise negation on a numeric expression.
~[Iteration] = 251
Not
!
Performs a logical negation on a Boolean expression.
Not [HasScreenshot]
![HasScreenshot]
+
Returns a numeric expression’s value (a unary operator).
+[Value] = 10
-
Returns the negative of a numeric expression’s value (a unary operator).
-[Value] = 20
Is Null
Returns true if an expression is a null reference, the one that does not refer to any object.
[ApplicationName] is null

Functions

Aggregate Functions

Function
Description
Example
Avg(Value)
Returns the average of all the values in the expression.
Avg([MeasurementTime])
Count()
Returns the number of values.
Count()
CountNotNull(Value)
Returns a number of non-null objects in a collection.
CountNotNull([MeasurementTime])
CountDistinct(Value)
Returns the number of distinct values.
CountDistinct([MeasurementTime])
Max(Value)
Returns the maximum value across all records.
Max([MeasurementTime])
Min(Value)
Returns the minimum value across all records.
Min([MeasurementTime])
Mode(Value)
Returns the mode of the values.
Mode([MeasurementTime])
Median(Value)
Returns the median of the values.
Median([MeasurementTime])
Sum(Value)
Returns the sum of all values.
Sum([MeasurementTime])
Var(Value)
Returns an estimate of the variance of a population, where the sample is a subset of the entire population.
Var([MeasurementTime])
Varp(Value)
Returns the variance of a population, where the population is the entire data to be summarized.
Varp([MeasurementTime])
StdDev(Value)
Returns an estimate of the standard deviation of a population, where the sample is a subset of the entire population.
StdDev([MeasurementTime])
StdDevp(Value)
Returns the standard deviation of a population, where the population is the entire data to be summarized.
StdDevp([MeasurementTime])

Logical Functions

Function
Description
Example
Iif(Expression1, True_Value1, …, ExpressionN, True_ValueN, False_Value)
Returns one of several specified values depending upon the values of logical expressions.
The function can take 2N+1 arguments (N - the number of specified logical expressions):
  • Each odd argument specifies a logical expression;
  • Each even argument specifies the value that is returned if the previous expression evaluates to true;
  • The last argument specifies the value that is returned if the previously evaluated logical expressions yielded false.
Iif([LoadBot]= ‘France’, 1, 0)
Iif([LoadBot] = ‘Paris’, 1, [LoadBot] = ‘Los Angeles’, 2, [LoadBot] = ‘Amsterdam’, 3, 0)
IsNull(Value)
Returns True if the specified Value is NULL.
IsNull([ApplicationName])
IsNull(Value1, Value2)
Returns Value1 if it is not set to NULL; otherwise, Value2 is returned.
IsNull([ApplicationName], [ActualTime])
IsNullOrEmpty(String)
Returns True if the specified String object is NULL or an empty string; otherwise, False is returned.
IsNullOrEmpty([ApplicationName])
ToBoolean(Value)
Converts Value to an equivalent Boolean value.
ToBoolean([Value])

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)
  • ==, !=
  • <, >, <=, >=
  • -, + (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.
Amount == 2 + 48 * 2
Amount == (2 + 48) * 2

Case Sensitivity

Operators are case insensitive. Although field values’ case sensitivity depends on the data source.

Escape Keywords

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’

Escape Characters

Use a backslash \ as an escape character for characters in expressions.
Examples:
  • \[
  • \\
  • \‘

Expression Comments

You can add a comment to your expression to explain it and make the expression more readable.
Comments are multi-line and begin with /* and end with */.

Was this article helpful?
0 out of 0 found this helpful