Expressions specify how to find or calculate a value when the report runs. Properties of a
Expressions allow you to:
Iif()
function is used to configure conditional values.Expressions in
To see a complete list of the operators, literals, and functions that you can use in expressions, see Operators, Literals, and Functions.
Follow the syntax conventions below when you create expressions:
Enclose data field names in square brackets ([]
), for example: [Products.ProductName]
Type a question mark (?) before query parameter names, for example: ?queryparameter
Add the Parameters
prefix before [Parameters.
report
parameter]
Enclose string literals in single quotes ('
), for example: 'USA'
The use of quotation marks ("
), for example, "Quoted Text"
, results in an error.
To embed an apostrophe into a string literal, type two apostrophes, for example: 'It''s an example'
The Boolean literals are True
and False
.
Enclose date-time literals in hash marks (#
), for example: [OrderDate] >= #1/1/2016#
Use a question mark (?
) to represent a null reference (one that does not refer to any object), for example: [Region] != ?
Use round brackets ()
to control the order in which an expression is evaluated, for example: 2 * ([Quantity] - 1)
If an expression contains terms of different types, you can use dedicated functions to convert the types, for example: Max(ToDecimal([Quantity]),[UnitPrice])
Refer to Operators, Literals, and Functions for a complete list of supported operators, literals, and functions.
String expressions are expressions that evaluate to a string. A complex string expression combines (concatenates) a number of string literals,+
.
String literals are enclosed in single quotes, for example, 'This is a string literal'
. Note that you cannot use double quotes ("
) instead of single quotations. To embed an apostrophe into a string literal, type a two apostrophes, for example, 'It''s an example'
appears in the report as: It's an example
Concatenating strings in an expression allows you to build complex strings that contain data. One common scenario is labelling data. For example, to label a record's object ID, you could use an expression like'Object ID: ' + [objectid]
. This appears in the report as, for example: Object ID: 19245
In other situations, you may want to build phrases or complete sentences. For example, the expression 'Towns with a population of ' + [MaxPop] + ' or less are eligible to apply for a ' + [ProgramName] + '.'
appears in the report as, for example: Towns with a population of 50000 or less are eligible to apply for a Small Town Improvement Grant.
You can configure multiple lines of text in a single string expression by using the NewLine()
function. For example, suppose you want to configure a Label control to present data for a person's name on the first line and the person's address on subsequent lines, such as the following:
Jennifer Scott
465 Mallory Lane
Denver, CO
80022
To do this, you could configure an expression like this:
[Name] + NewLine() + [StreetAddress] + NewLine() + [City] + ', ' + [State] + NewLine() + [ZipCode]
As an alternative to the +
concatenation operator, you can use the Concat()
function to concatenate any number of strings. For example, to label data, you could use an expression like this: Concat('Object ID: ', [objectid])
See also...
You can use conditional values in a report by using the logical function, Iif()
. The Iif()
function takes three arguments: a Boolean expression, a value to use if the Boolean expression evaluates to True
, and a value to use if the Boolean expression evaluates to False
. The arguments are separated by commas: Iif(BoolenExpression, TruePart, FalsePart)
.
Iif([BooleanField],True,False)
. True
and False
, for example, Iif([RoadClosed], 'Road Closed', 'Road Open')
. The conditional values do not have to be literals—they can be expressions. For example, Iif([CropArea]<=10, 'Livestock: '+[HasLivestock]+' Produce: '+[HasProduce]+' Flowers: '+[HasFlowers], 'Not a market garden')
.
Expression |
Result Type |
Description |
---|---|---|
|
Same as the type of the data field |
Evaluates to the value of the |
|
String |
Concatenates the "Object ID: " string with the value of the |
|
String |
Concatenates the value of the current record's |
|
Numeric |
Calculates the difference between the values of the |
|
String |
Concatenates the "Population Change: " string with the difference between |
|
Boolean |
Evaluates to |
|
Boolean |
Evaluates to An expression similar to this is used to present the current selection set in the report. See Use the Current Features as Report Inputs. |
|
Date |
Evaluates to today's date, for example: 23 July, 2018
|