dbTalk Databases Forums  

MDX: Moving Cross Joins to WHERE

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


Discuss MDX: Moving Cross Joins to WHERE in the microsoft.public.sqlserver.olap forum.



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

Default MDX: Moving Cross Joins to WHERE - 01-06-2006 , 05:58 AM






I'm building an application which builds dynamic MDX according to user
choices. This is done incrementally. So for example if there are 3
dimensions A, B and C. The first piece of MDX will use the A criteria
as the rows dimension. In the 2nd B is the focus but including the
criteria of A. in the 3rd query C is the focus but including the
criteria for A and B. In an SQL query this would result in query 3
being Select C criteria WHERE A = and B= and C =

Pretending all are ranges of ID's from 1 to 10 then this may be (in SQL
like form)

SELECT C
FROM CUBE
WHERE
A IN (1, 2, 3, 4, 5)
AND
B IN (6, 7, 8, 9)
AND
C IN (2, 4, 6, 8)

However I don't seem to be able to do this in MDX. So far I have done
this using crossjoins and compiled the data into the desired format in
code. Does anyone know if there is a way to move my crossjoins to a
WHERE clause (as long as the selection criteria is trhe same I'm happy
to trim the volume of Cells)? I'm assuming that even asking this
question is to misunderstand the nature of Cubes but I thought I'd
check!

Sample

SELECT CROSSJOIN ({[ProfileQtr].Children}, {[Measures].Children}) on
columns,
CROSSJOIN(CROSSJOIN(CROSSJOIN({[A].[1], [A].[2], [A].[3]}, {[b].[1],
[b].[2], [b].[3]}), {[C].[1], [C].[2], [C].[3]})) on rows
FROM Cube

Would like something like

SELECT CROSSJOIN ({[ProfileQtr].Children}, {[Measures].Children}) on
columns,
{[C].[1], [C].[2], [C].[3]} on rows
FROM Cube
WHERE
([A].[1], [A].[2], [A].[3], [b].[1], [b].[2], [b].[3])


Thanks,

Ben.


Reply With Quote
  #2  
Old   
Vladimir Chtepa
 
Posts: n/a

Default Re: Moving Cross Joins to WHERE - 01-06-2006 , 10:49 AM






Hi,

How large is your set [ProfileQtr].Children?
Nestet crossjoin ist not good idea. Try to use NonEmptyCrossjoin. It has
essentially better performance.
You could rewrite your query in following form.

WITH
MEMBER [A].[MY_MEMBER] as SUM({[A].[1], [A].[2], [A].[3]},
Measures.CURRENTMEMBER)
MEMBER [b].[MY_MEMBER] as SUM({[b].[1], [b].[2], [b].[3]},
Measures.CURRENTMEMBER)
SELECT
CROSSJOIN({[ProfileQtr].Children}, {[Measures].Children}) on columns,
{[C].[1], [C].[2], [C].[3]} on rows
FROM Cube
WHERE ([A].[MY_MEMBER], [b].[MY_MEMBER])

Is it what you need?

Thanks,
Vladimir Chtepa

"Ben" <gringogordo (AT) hotmail (DOT) com> schrieb im Newsbeitrag
news:1136548687.595719.263410 (AT) g47g2000cwa (DOT) googlegroups.com...

Quote:
I'm building an application which builds dynamic MDX according to user
choices. This is done incrementally. So for example if there are 3
dimensions A, B and C. The first piece of MDX will use the A criteria
as the rows dimension. In the 2nd B is the focus but including the
criteria of A. in the 3rd query C is the focus but including the
criteria for A and B. In an SQL query this would result in query 3
being Select C criteria WHERE A = and B= and C =

Pretending all are ranges of ID's from 1 to 10 then this may be (in SQL
like form)

SELECT C
FROM CUBE
WHERE
A IN (1, 2, 3, 4, 5)
AND
B IN (6, 7, 8, 9)
AND
C IN (2, 4, 6, 8)

However I don't seem to be able to do this in MDX. So far I have done
this using crossjoins and compiled the data into the desired format in
code. Does anyone know if there is a way to move my crossjoins to a
WHERE clause (as long as the selection criteria is trhe same I'm happy
to trim the volume of Cells)? I'm assuming that even asking this
question is to misunderstand the nature of Cubes but I thought I'd
check!

Sample

SELECT CROSSJOIN ({[ProfileQtr].Children}, {[Measures].Children}) on
columns,
CROSSJOIN(CROSSJOIN(CROSSJOIN({[A].[1], [A].[2], [A].[3]}, {[b].[1],
[b].[2], [b].[3]}), {[C].[1], [C].[2], [C].[3]})) on rows
FROM Cube

Would like something like

SELECT CROSSJOIN ({[ProfileQtr].Children}, {[Measures].Children}) on
columns,
{[C].[1], [C].[2], [C].[3]} on rows
FROM Cube
WHERE
([A].[1], [A].[2], [A].[3], [b].[1], [b].[2], [b].[3])


Thanks,

Ben.




Reply With Quote
  #3  
Old   
Ben
 
Posts: n/a

Default Re: Moving Cross Joins to WHERE - 01-06-2006 , 11:35 AM



Sorry to display my ignorance - is it possible to use WITH MEMBER in
the MDX sample app. I'm getting an invalid Axis Definition. Should I
play with my syntax or is it not something the sample app does.

Thanks.


Reply With Quote
  #4  
Old   
Ben
 
Posts: n/a

Default Re: Moving Cross Joins to WHERE - 01-06-2006 , 11:53 AM



This appears to be exactly what I needed. Many thanks.


Reply With Quote
  #5  
Old   
Vladimir Chtepa
 
Posts: n/a

Default Re: Moving Cross Joins to WHERE - 01-07-2006 , 05:43 AM



If you use AS2000, calculated member schould be defined in ''.

WITH
MEMBER [A].[MY_MEMBER] as 'SUM({[A].[1], [A].[2], [A].[3]},
Measures.CURRENTMEMBER)'
MEMBER [b].[MY_MEMBER] as 'SUM({[b].[1], [b].[2], [b].[3]},
Measures.CURRENTMEMBER)'
SELECT
CROSSJOIN({[ProfileQtr].Children}, {[Measures].Children}) on columns,
{[C].[1], [C].[2], [C].[3]} on rows
FROM Cube
WHERE ([A].[MY_MEMBER], [b].[MY_MEMBER])


"Ben" <gringogordo (AT) hotmail (DOT) com> wrote

Quote:
Sorry to display my ignorance - is it possible to use WITH MEMBER in
the MDX sample app. I'm getting an invalid Axis Definition. Should I
play with my syntax or is it not something the sample app does.

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.