Database Reference
In-Depth Information
Do not worry about when this will or will not occur. Just add the CurrentMember function to an expression
whenever you get an error about an expression being ambiguous, and this will often resolve the issue. it is not very
scientific, but it is easy to remember.
Tip
The Order Function
Ordering results is a common task in SQL programming. This is also true of MDX programming. Many of the
client software applications that work with SSAS do the sorting for you after receiving the results of an MDX
query. But, on occasion, you may want to sort the results beforehand. You can do so by using the Order function.
he Order function in MDX works slightly different from the Order By clause in SQL programming because
of the hierarchical nature of a cube. To understand this, let's first take a look at the results of a query with no
Order function, as shown in Listing 14-33. See Figure 14-26 for some of the results.
Figure 14-26. The partial results of the example in Listing 14-33
Listing 14-33. An MDX Query Without the Order Function
Select
{ [Measures].[SalesQuantity] } On Columns,
{ [DimTitles].[TitlesByPublishers].AllMembers } On Rows
From [CubePubsSales];
In the Pubs database, New Moon Books and Binnet & Hardley are publishers. Figure 14-26 shows that the
results of the code in Listing 14-28 have been automatically grouped based on the publishers that the books fall
under. Currently, the order the titles appear in is based on the position of each member's key value. The unsorted
results display the title with a lower key value before the title with a higher key value. If you look up the key
values, you will find that the title Is Anger the Enemy? has a key value of 8, while the title Life without Fear has a
key value of 13. Therefore, the title Is Anger the Enemy? is displayed first.
 
 
Search WWH ::




Custom Search