Hi All,
The following query returns 4 members ([Gross Sales], [Trade Sales], [Intercompany Sales], [Trade Sales]) while it should return only 3. DISTINCT function does not remove the duplicated member [Trade Sales].
SELECT
{[Measures].[Amount]}
ON AXIS(0),
DISTINCT (DESCENDANTS({ [Account].[Accounts].[Gross Sales],
[Account].[Accounts].[Trade Sales]}, 0, self_and_after))
ON AXIS(1)
FROM [ADVENTURE WORKS]
Any inputs will be appreciated.
David.
DISTINCT must follow SELECT:
Code Snippet SELECT DISTINCT (DESCENDANTS({ [Account].[Accounts].[Gross Sales], [Account].[Accounts].[Trade Sales]}, 0, self_and_after)) ON AXIS(1), {[Measures].[Amount]} ON AXIS(0), FROM [ADVENTURE WORKS]
Adamus
|||Seems to be a bug, since if you statically list the members, Distinct() seems to work:
Code Snippet
SELECT
{[Measures].[Amount]} ON AXIS(0),
Distinct({[Account].[Accounts].[Gross Sales],
[Account].[Accounts].[Trade Sales],
[Account].[Accounts].[Intercompany Sales],
[Account].[Accounts].[Trade Sales]}) ON AXIS(1)
FROM [ADVENTURE WORKS]
Using Generate() instead of Distinct() also seems to work:
Code Snippet
SELECT
{[Measures].[Amount]} ON AXIS(0),
Generate(DESCENDANTS({[Account].[Accounts].[Gross Sales],
[Account].[Accounts].[Trade Sales]}, 0, self_and_after),
{[Account].[Accounts].CurrentMember}) ON AXIS(1)
FROM [ADVENTURE WORKS]
|||Thx, Deepak.
The question remains: is it just a bug or there is some hidden meaning to this behavior?
Curiously, if instead of DISTINCT you apply other functions that should remove duplicates,
the duplicates still remain, for example, UNION with an empty set:
UNION(DESCENDANTS({[Account].[Accounts].[Gross Sales], [Account].[Accounts].[Trade Sales]}, 0, self_and_after), {})
No comments:
Post a Comment