So in brief, I will explore the Name, Key and Level of an All member in a dimension hierarchy. The one of choice was the Customer dimension and Customer Geography hierarchy in Adventure Works. There is an All member, called All Customers. As expected, .PROPERTIES("MEMBER_NAME") gives us "All Customers":
WITHThe first row shows us: All Customers.
MEMBER [Measures].[test] AS
[Customer].[Customer Geography].CurrentMember.PROPERTIES("MEMBER_NAME")
SELECT
{
[Measures].[test]
} ON 0,
{
[Customer].[Customer Geography].Members
} ON 1
FROM [Adventure Works]
Now, let's see what its key is:
WITHThis gives us 0.
MEMBER [Measures].[test] AS
[Customer].[Customer Geography].CurrentMember.PROPERTIES("KEY")
SELECT
{
[Measures].[test]
} ON 0,
{
[Customer].[Customer Geography].Members
} ON 1
FROM [Adventure Works]
And its level:
WITHThe result this time is: (All).
MEMBER [Measures].[test] AS
[Customer].[Customer Geography].CurrentMember.Level.Name
SELECT
{
[Measures].[test]
} ON 0,
{
[Customer].[Customer Geography].Members
} ON 1
FROM [Adventure Works]
So far so good. Now let's try using these to get only the All member:
SELECTThis works. Now if we try the Key:
{
[Customer].[Customer Geography].[All Customers]
} ON 0
FROM [Adventure Works]
SELECTInterestingly, since the All member is a calculated member and has no physical key, if we try to use the one that SSAS gave us does not actually work - we get nothing on Axis 0.
{
[Customer].[Customer Geography].&[0]
} ON 0
FROM [Adventure Works]
Using the level works:
SELECTAlso, after experimenting a bit further:
{
[Customer].[Customer Geography].[(All)].Item(0)
} ON 0
FROM [Adventure Works]
SELECTThis query also works even though the All member name is [All Customers], not just [All]. However, Analysis Services does recognise [All].
{
[Customer].[Customer Geography].[All]
} ON 0
FROM [Adventure Works]
In summary, the most robust options for referencing the All member in a dimension hierarchy that I have found are:
1. [Dimension].[Hierarchy].[(All)].Item(0)
2. [Dimension].[Hierarchy].[All]
These will always work - regardless of the dimension and hierarchy names.
Another option is using [Dimension].[Hierarchy].[
And, one that does not work - referencing through its alleged key: [Customer].[Customer Hierarchy].&[0]
Please let me know if there are any better alternatives, or why it would give me a key of 0 for the All member and would not work when actually using this key.

