Introducing the SQL Server 'MDX in Analysis Services' Series - Page 4
December 2, 2002
A "Platform for Exploration:" Simple Calculated Members
Let's create a simple calculated member to get a look at its properties in a general way. We will also use our newly created calculated member to explore other facets of MDX as we progress through the tutorial. From the Analysis Manager console, and at the Cubes folder within the FoodMart 2000 database sample,
- Expand the Cubes folder (seen in the illustration below) by clicking the "+" sign to its left.
Illustration 3: Sample Cubes provided with the Analysis Services Installation
- Right click the Warehouse cube, then click Edit from the flyout menu.
- When the Cube Editor screen appears, click the Data tab at the lower left (on the right half of the screen).
The preview pane is activated.
- If "Product Family" does not appear in the lower pane area, drag the Product dimension to the rows area (the left column of the lower pane section).
The Cube Editor preview pane should appear as shown below in Illustration 4.
Illustration 4: The Cube Editor Preview Pane
- Select Insert Calculated Member (top drop down menu) under Insert. A picture of the associated toolbar button, an alternative means of initializing the Calculated Member Builder, appears below.
Illustration 5: The Insert Calculated Member Toolbar Button
The Calculated Member Builder appears.
- Type MyCalcMem into the Member Name box. In the Value Expression box, input the phrase "Check for Updates" (quotation marks required). The Value Expression box should appear as shown below.
Illustration 6: The Value Expression Dialog Box with Inserted String
- Click OK.
- Review the newly created MyCalcMem column, comparing it to the illustration below.
Illustration 7: The New MyCalcMem Column
To change the expression for MyCalcMem, go to the Calculated Members folder in the Cube tree in the left pane of the Cube Editor, as partially shown below.
Illustration 8: MyCalcMem now appears in the Calculated Member Folder
- Click MyCalcMem within the Calculated Members folder.
- Right click and select Edit.
- Type 11+2.
- Click OK.
Standard mathematical operations apply here. For details, see the Online Books for Analysis Services/MSSQL Server 2000.
- The number 13 fills the MyCalcMem column cells, replacing the "Check for Updates" string.
To perform a text concatenation,
- Select the Properties pane at the bottom of the left side of the Cube Editor, ensuring that MyCalcMem (in the Calculated Members folder of the Cube tree) remains highlighted.
- Select the Value property for MyCalcMem to edit its properties.
- Click the ellipsis (...) button, and, when the Calculated Member Builder appears, clear the Value Expression box.
- Type in the following:
"MyCalcMem" + "-" + "REVISION1"
The contents of the Value Expression box should resemble those depicted in Illustration 9 below.
Illustration 9: Text Concatenation in the Value Expression Box
- Click OK. Compare the results to the partial illustration shown.
Illustration 10: Text Concatenation Results for MyCalcMem in the Preview Pane
As we have seen, the result of placing "+" between two numbers in an MDX expression is the sum of the numbers, while the "+" sign used between two strings returns a concatenated string. (Remember that strings need to be enclosed in quotation marks.)
Page 5: "Getting Familiar with the Membership" with MDX Expressions
See All Articles by Columnist William E. Pearson, III