dbTalk Databases Forums  

Partial solution to "SELECT DISTINCT" in MDX problem - how tocomplete solution?

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss Partial solution to "SELECT DISTINCT" in MDX problem - how tocomplete solution? in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Mike
 
Posts: n/a

Default Partial solution to "SELECT DISTINCT" in MDX problem - how tocomplete solution? - 01-30-2012 , 05:14 AM






I have a fairly complex cube with numerous dimensions, the principal
one having the following hierarchy

[Class] > [SubClass1] > [SubClass2] > [Primary Ref] > [Secondary Ref]

[Secondary ref] is not a leaf. I wish it were.

The hierarchy also has a couple of attributes which are descriptions
of the subclasses.

The table has a number of financials and a [Transaction Count] member.

I need to be able to give a number of distinct [Primary Ref]s and
[Secondary Ref]s in the cube as two calculated members. I can't use
[Transaction Count] as the fact table contains multiple entries for
each reference. It appears I'm not the first to ask about this, but
all the suggestions I've tried either don't work or don't seem to
apply to calculated members.

I'd rather avoid having to write C# functions to get this done.

My solution has been the following:

WITH MEMBER [SecondaryRefCount] AS
IIF(DISTINCTCOUNT(DESCENDANTS([Class].[Class of
Business].CurrentMember,[Class].[ClassHierarchy].[Secondary
Ref],SELF))=0,
Null,
DISTINCTCOUNT(DESCENDANTS([Class].[Class of Business].CurrentMember,
[Class].[ClassHierarchy].[Secondary Ref],SELF))
)

There's a similar calc member for the primary ref.

If I use the Class hierarchy itself, and/or put attributes /
hierarchies from other dimensions on the axes they seem to work fine.

This seems to work fine in all scenarios but one. If I put one of the
non-hierarchy attributes ([SubClass1Description]) on an axis, the
function fails to filter on that value and I get the totals for all
SubClass1Descriptions. Somehow there doesn't seem to be a causal link
between the attribute at the hierarchy, and I have no idea how to
simulate one.

I can get round this (sort of) by removing the attibutes from my Class
dimension, but I'd rather not. It appears what I need to do is tie the
[SubClass1Description] and [SubClass2Description] attributes to the
[Class].[ClassHierarchy], but I don't want them to be visible there so
I can't include them in the hierarchy itself.

Can anyone help? I'm SOOO close to getting this to work exactly as
required.

Many thanks!

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.