dbTalk Databases Forums  

Filter dimension by another dimension's attribute or name

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


Discuss Filter dimension by another dimension's attribute or name in the microsoft.public.sqlserver.olap forum.



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

Default Filter dimension by another dimension's attribute or name - 10-03-2005 , 10:31 PM






Hello,

I have two dimensions which represent the source and destination of stock
movements. I want to filter the destination dimension to remove those which
are "equivalent" to any selected member(s) on the source dimension. I have
tried using names and properties to define "equivalence".

At first I tried something simple like this:

FILTER (
[Destination].[InvPoint].[Inventory Point].Members,
[Destination].[InvPoint].CurrentMember.name <> [Branch
Plant].[InvPoint].CurrentMember.name
)

This parses OK but simply gets it wrong. It appears that the
"currentMember" context for the [Branch Plant].[InvPoint] dimension is not
coming from the axis. This filter does NOT remove destinations with the same
name as the source. (If I substitute a literal for the [Branch Plant] name,
it works.)

When I try using Properties, it gets worse. The code which follows fails to
parse, because the property "BrInvPointName" is not valid!

FILTER (
[Destination].[InvPoint].[Inventory Point].Members,
[Destination].[InvPoint].CurrentMember.Properties("InvPointName") <>
[Branch Plant].[InvPoint].CurrentMember.Properties("BrInvPointName")
)

If I swap the dimensions, the property "InvPointName" becomes not valid.
Weird.

I tried using GENERATE outside the FILTER, but essentially it does the same
thing.

Please help - some days I think I am begining to understand MDX then
something like this happens.

Les



Reply With Quote
  #2  
Old   
Deepak Puri
 
Posts: n/a

Default Re: Filter dimension by another dimension's attribute or name - 10-04-2005 , 01:38 AM






Hi Les,

Can you give an example of the MDX query you're using, because it's not
clear how the selected member(s) of the source dimension are to be
identified. Presumably, the destination dimension Filter() results are
to be placed on a query axis; but is the objective to remove all members
which can link to source members on another axis? In that case, you
would need to use a set of source members.


- Deepak

Deepak Puri
Microsoft MVP - SQL Server

*** Sent via Developersdex http://www.developersdex.com ***

Reply With Quote
  #3  
Old   
Les Russell
 
Posts: n/a

Default Re: Filter dimension by another dimension's attribute or name - 10-04-2005 , 02:10 AM



Deepak,

Thanks - your question has hit the nail on the head. I was trying to run it
without giving the [Branch Plant].[InvPoint] a context (if that's the right
jargon). When I use the following MDX, it works:

Quote:
SELECT { [Time].[Financial].[All Time] } ON COLUMNS , {
[<##<SET!lrussell!SelectDestName>##>] } ON ROWS FROM
[Sales_Tonnes_FcstAccuracy] WHERE ( [Branch Plant].[InvPoint].[Branch
State].&[NSW].&[Sydney].&[SydFG], [Company].[Company Code].&[00010],
[Measures].[Product Tonnes] )
<<<<<<<<<
(Here the expression [<##<SET!lrussell!SelectDestName>##>] represents a
custom set generated in ProClarity using the code from my first post.)

For your info, the code which does NOT work is:
Quote:
SELECT { [Time].[Financial].[All Time] } ON COLUMNS , { { {
[<##<SET!lrussell!SelectDestName>##>] } * { [Branch Plant].[InvPoint].[Branch
State].&[NSW].&[Sydney].&[SydFG] } } } ON ROWS FROM
[Sales_Tonnes_FcstAccuracy] WHERE ( [Company].[Company Code].&[00010],
[Measures].[Product Tonnes] )
<<<<<<<<<<

Thanks for your help,
Les

PS - this is just the first step in what I'm trying to do. I may be back
for more help :P


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.