Database Reference
In-Depth Information
Figure 14-37. MDX code automatically generated by the cube browser
Listing 14-41. he Automatically Generated MDX Code
SELECT NON EMPTY { [Measures].[SalesQuantity] } ON COLUMNS, NON EMPTY {
([DimDates].[Year].[Year].ALLMEMBERS * [DimTitles].[Title].[Title].ALLMEMBERS ) }
DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM [CubePubsSales]
CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING,
FONT_NAME, FONT_SIZE, FONT_FLAGS
reusing the Code
As you can see, the code needs a little work before we would want to use it as our own MDX code. Let's
clean it up and test it in a regular MDX query window.
1.
Highlight all of the MDX code in the designer window, right-click, and select Copy
from the context window.
2.
Click the new Query button to create a new MDX coding window, as circled in
Figure 14-6 . Paste the MDX code into the new MDX coding window that opens. The
code will be presented on a single line, without any carriage returns.
3.
Add carriage returns to the MDX code so that it displays like the code shown in
Listing 14-42.
Listing 14-42. Reformatting the Automatically Generated MDX Code
SELECT
NON EMPTY { [Measures].[SalesQuantity] } ON COLUMNS
, NON EMPTY { (
[DimDates].[Year].[Year].ALLMEMBERS
*
[DimTitles].[Title].[Title].ALLMEMBERS
) } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME
ON ROWS
FROM [CubePubsSales]
CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING,
FONT_NAME, FONT_SIZE, FONT_FLAGS
4.
Highlight the select statement within your reformatted code, right-click, and select
the Execute option. Alternately, you can run the query by clicking the “! Execute”
button on the toolbar.
5.
Verify that your results match the results shown in Figure 14-36 .
Search WWH ::




Custom Search