return top 5.... under specifcied dimension join another

Dear all,

i'm working on this problem and see any one can give me insight:

my MDX statement is to get a top 5 data from a cube with some dimensions.. should be pretty simple .. looking like this..

Select { [Measures].[grsamount]} on columns,
non empty {topCount ([Distributors].[Distributors Groups].[Distributor Group ABC].children, 5, [Measures].[grsamount]) } on rows
from [transactions] where ([time].[all time].[2006].[q2].[jun],
[Transaction Status].[Status].[Settled], [Sales Office].[All Sales Office].[US])

This working fine and returns me a result like..

Distributor A, $1
Distributor B, $2
(assume there is only 2 distributors under Distributor Group ABCAND US office)

However, i have to retrieve a dimension properties of Internal code and I'm using the WITH MEMBER to do this and put it in the columns .. as below:

WITH MEMBER [MEASURES].[Distributor_Code] as
'Distributors.CurrentMember.Properties ("Dist_InternalCode") '
Select { [Measures].[grsamount], [MEASURES].[Distributor_Code] } on
columns,
non empty {topCount ([Distributors].[All Distributors].[Distributor ABC].children, 5, [Measures].[grsamount]) } on rows
from [transactions] where ([time].[all time].[2006].[q2].[jun],
[Transaction Status].[Status].[Settled], [Sales Office].[All Sales Office].[US])

Problem is.. this time the return is as :

Distributor A, $1
Distributor B, $2
D
istributor X
Distributor Y
Distributor Z

The Distributor X, Y, Z belongs to Distributor Group ABC as well butnot belongs to US office. However the result returned includes X, Y, Z distributor as well... Do any one know why and how to correct this?

Slightly urgent as the report with MDX is already in production but it's doing olap structure change and turn out to have this problem... Customer is still using OLAP 2000.. pls advice.

Regards, Andy



[2798 byte] By [happyman] at [2007-12-22]
# 1
I have logged a bug with Microsoft (see http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=549706&SiteID=1) regarding TOPCOUNT. They are still working on it.
centexbi at 2007-8-30 > top of Msdn Tech,SQL Server,SQL Server Analysis Services...
# 2

oh thanks for ur reply.. but i'm using SQL 2005 (:p sorry about this.. )

it seems the 'Distributors.CurrentMember.Properties..... " is affecting the returned result on the rows when there is topcount...
even there is no GrsAmount (empty) ...it seems it found values for the MemberProperties and thus display the value..

Any way to avoid that?

there is no problem on the statement before when there is no [Sales Office] dimension ...

WITH MEMBER [MEASURES].[Distributor_Code] as
'Distributors.CurrentMember.Properties ("Dist_InternalCode") '
Select { [Measures].[grsamount], [MEASURES].[Distributor_Code] } on
columns,
non empty {topCount ([Distributors].[All Distributors].[Distributor ABC].children, 5, [Measures].[grsamount]) } on rows
from [transactions] where ([time].[all time].[2006].[q2].[jun],
[Transaction Status].[Status].[Settled] , [Sales Office], [Sales Office].[All Sales Office].[US])

happyman at 2007-8-30 > top of Msdn Tech,SQL Server,SQL Server Analysis Services...
# 3

You could try setting the calculated measure [Distributor_Code] to null when [grsamount] is empty:

WITH MEMBER [MEASURES].[Distributor_Code] as
'Distributors.CurrentMember.Properties ("Dist_InternalCode") '

Member [Measures].[Dist_Code_Nullable] as

'iif(IsEmpty([Measures].[grsamount]), Null,

[Measures].[Dist_Code_Nullable])'


Select { [Measures].[grsamount], [MEASURES].[Dist_Code_Nullable] } on
columns,
non empty {topCount ([Distributors].[All Distributors].[Distributor ABC].children, 5, [Measures].[grsamount]) } on rows
from [transactions] where ([time].[all time].[2006].[q2].[jun],
[Transaction Status].[Status].[Settled], [Sales Office].[All Sales Office].[US])

DeepakPuri at 2007-8-30 > top of Msdn Tech,SQL Server,SQL Server Analysis Services...
# 4

hello Deepak

yes bingo.. thansk very much .. it works .

(just minor modification in below.. )

Member [Measures].[Dist_Code_Nullable] as 'iif(IsEmpty([Measures].[usd grsamount]), Null, [Measures].[Distributor_code])'

happyman at 2007-8-30 > top of Msdn Tech,SQL Server,SQL Server Analysis Services...

SQL Server

Site Classified