Comments in MDX

Analysis Services

Analysis Services

Comments in MDX

Statements in Multidimensional Expressions (MDX) can contain user-readable comments that are ignored when the commands are processed. The three different character sets that indicate comments are outlined in the following table.

Characters Description
// C++-style forward slashes. All text between the forward slashes and the end of the same line is ignored.
-- SQL-style hyphens. All text between the dashes and the end of the same line is ignored.
/*...*/ C-style forward slash and asterisk pairs. All text between the opening forward slash and asterisk and the closing asterisk and backward slash is ignored. This type of comment can span multiple lines.

The following example shows the use of comments in an MDX command:

/* Using this query to view 
   info about units shipped 
   and units ordered  */

WITH MEMBER [Measures].[ShippingPercent] AS
'-- Returns [Units Shipped] over [Units Ordered] as a percent value
Measures.[Units Shipped] / Measures.[Units Ordered]',
FORMAT_STRING = 'Percent'

SELECT
   { [Measures].[Units Shipped], [Measures].[Units Ordered], [Measures].[ShippingPercent] } ON COLUMNS,
// The next command specifies nonempty members only
   NON EMPTY [Store].[Store Name].Members ON ROWS
FROM Warehouse   -- Pulled from the Warehouse cube

Comments are recommended in complex or difficult to understand MDX queries, because they add information without incurring performance penalties.