Expressions (MDX)
An expression is a combination of identifiers, values, and operators that Microsoft SQL Server 2005 Analysis Services (SSAS) can evaluate to get a result. The data can be used in several different places when accessing or changing data. For example, you can use an expression as part of the data to be retrieved by a query or as a search condition to look for data that meets a set of criteria.
Simple and Complex Expressions
An expression can be simple or complex in MDX:
A simple expression can be one of the following expressions:
- Constant
A constant is a symbol that represents a single, specific value in MDX. String, numeric, and date values can be rendered as constants. Unlike numeric constants, string and date constants must be delimited with single quote (') characters.
- Scalar function
A scalar function returns a single value within the context of evaluation in MDX. This distinction is important to understanding how MDX resolves scalar functions, because most MDX expressions, statements, and scripts are evaluated not over a single data element, but iteratively over a group of data elements such as cells or members. At the time the scalar function is evaluated, however, the function is typically reviewing a single data element.
- Object identifier
MDX is object-oriented because of the nature of multidimensional data. Object identifiers are considered simple expressions in MDX. For more information on identifiers, see Identifiers (MDX).
- Variable
MDX scripts can contain user-defined variables to retain information. Variables can only be used in expressions and cannot replace keywords or object identifiers.
A complex expression can be built from combinations of these entities joined by operators.
Expression Results
For a simple expression built of a single constant, variable, scalar function, or column name, the data type, collation, precision, scale, and value of the expression is the data type, collation, precision, scale, and value of the referenced element. Because MDX directly supports only the OLE VARIANT data type, coercion should not occur when working with simple expressions.
For a complex expression, coercion can occur when using two or more simple expressions with different data types.
Expression Examples
An expression can also be a calculation, such as [Measures].[Discount Amount] * 1.5
. The following example demonstrates the use of a calculation to define a member in an MDX SELECT statement:
WITH
MEMBER [Measures].[Special Discount] AS
[Measures].[Discount Amount] * 1.5
SELECT
[Measures].[Special Discount] on COLUMNS,
NON EMPTY [Product].[Product].MEMBERS ON Rows
FROM [Adventure Works]
In This Section
Topic | Description |
---|---|
Defines cube and subcube expressions. |
|
Defines dimension expressions. |
|
Defines member expressions. |
|
Defines tuple expressions. |
|
Defines set expressions. |
|
Defines scalar expressions. |
|
Describes what an empty value is and how such values are handled. |