Database Reference
In-Depth Information
Figure 14-12. The results of the example in Listing 14-17
Listing 14-17. Adding a Calculated Member
-- Adding a Calculated Member
With Member Measures. [test]
As
"test data" --String data (uses Double Quotes)
-- Note: using Single Quotes causes an Error
Select
{ [Measures].AllMemebers } On Columns
From [CubePubsSales];
Many developers expect the calculated member syntax to indicate the end of an expression. it is clear that
the expression begins after the As keyword, but there is no clear indicator of where it ends. Because of this, many
new developers try including curly braces to encompass the expression. Doing so causes an error.
Note
Calculated members are evaluated as either string or numeric data. Use double quotes to indicate that the
value is a string. This is different from SQL programming that uses a single quote to indicate a string. Use literal
values for numeric data.
For mathematical expressions, specify the literal values and operator as you would any other programming
language. It is good practice to include parentheses around the expressions, but they are not strictly necessary.
Although it may seem odd, you can use single quotes to surround an expression. Remember that in MDX,
double quotes indicate a string of characters, not single quotes.
The three examples in Listing 14-18 highlight this calculated member syntax. The first query and third
queries return the same result (shown in Figure 14-13 ).
 
Search WWH ::




Custom Search