1

I have a SQL data cube with following hierarchy

enter image description here

I want to cross join Warehouse division and Code warehouse Desc. I wrote a MDX as follows

SELECT NON EMPTY 
{ [Measures].[Total  Value]} 
DIMENSION PROPERTIES CHILDREN_CARDINALITY, 
PARENT_UNIQUE_NAME ON COLUMNS, 
NON EMPTY 
{      
   [Combined].[Drill Down Path 4].[Warehouse Division].MEMBERS*   [Combined].[Drill Down Path 4].[Code Warehouse Desc].MEMBERS
} 
DIMENSION PROPERTIES MEMBER_CAPTION ON ROWS FROM [InventoryAge]
WHERE ( [Calendar].[Report Days].[All Members].&[All].&[WantInReport].& [2].&[20141031] )

It gives me an error as follows

Query (13, 8) The Drill Down Path 4 hierarchy is used more than once in the Crossjoin function.

Can any body suggests a better way to do this

Please find the calender hierarchy

enter image description here

udaya726
  • 1,010
  • 6
  • 21
  • 41

2 Answers2

2

You don't need to crossjoin hierarchy (this is impossible) to do what you need. Just query the lowest level of it, you will get all parents also

SELECT NON EMPTY 
{ [Measures].[Total  Value]} 
DIMENSION PROPERTIES CHILDREN_CARDINALITY, 
PARENT_UNIQUE_NAME ON COLUMNS, 
NON EMPTY 
{      
     [Combined].[Drill Down Path 4].[Code Warehouse Desc].allMEMBERS
} 
 DIMENSION PROPERTIES MEMBER_CAPTION ON ROWS FROM [InventoryAge]
 WHERE ( [Calendar].[Report Days].[All Members].&[All].&[WantInReport].& [2].&[20141031] )

PS. You might not be able to see them in SSMS query result viewer, but they will appear if you use query in cube browser or as dataset in SSRS/other tool

George
  • 692
  • 5
  • 10
0

You can pass last date in your set by using Tail(Existing [Calendar].[Report Days].[All Members].&[All].&[WantInReport].members, 1).item(0)

Or you can use Format(Now()), which gives you string representation of current system date. However, it depends on locale, so you probably need to remove dots/slashes. See here

George
  • 692
  • 5
  • 10
  • I used following query to get the value you mentioned. But it gives me an error with member [Measures].[Yesterday] as Tail(Existing [Calendar].[Report Days].[All Members].&[All].&[WantInReport].MEMBERS, 1).item(0) , FORMAT_STRING='yyyyMMdd' select { [Measures].[Yesterday]} ON Columns FROM [InventoryAge] – udaya726 Feb 06 '15 at 09:05
  • Could you please attach picture of your Calendar Hierarchy? In general, you get last date by this: Tail(Existing [Calendar].[Days].members, 1).Item(0) However, you structure seems different. To get its value in Measures, you need Tail(Existing [Calendar].[Days].members, 1).Item(0).memberValue – George Feb 06 '15 at 10:29