# Expressions (MDX)

**SQL Server 2008**

An expression is a combination of identifiers, values, and operators that Microsoft SQL Server Analysis Services 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.

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.

The following query shows examples of calculated measures whose definitions are simple expressions:

WITH

MEMBER MEASURES.CONSTANTVALUE AS 1

MEMBER MEASURES.SCALARFUNCTION AS [Date].[Calendar Year].CURRENTMEMBER.NAME

MEMBER MEASURES.OBJECTIDENTIFIER AS [Measures].[Internet Sales Amount]

SELECT {MEASURES.CONSTANTVALUE,MEASURES.SCALARFUNCTION,MEASURES.OBJECTIDENTIFIER } ON 0,

[Date].[Calendar Year].MEMBERS ON 1

FROM [Adventure Works]

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] WHERE [Product].[Category].[Bikes]