I recently used excel to connect to analysis services and generate a mdx code that was used to query the cube. The code is shown below. The code was also verified using sql profiler. However when I go to analysis services and browse the cube and put in the cube in management studio, I get errors. Please let me know if the code can be fixed. This code is exactly what i need for my requirements so if there are any modifications please replace it within the cube itself.
Code
SELECT NON EMPTY Hierarchize(DrilldownMember(CrossJoin({
[ColorsDim].[PrimeColor].[All], [ColorsDim].[PrimeColor].[PrimeColor].AllMember},
{([ColorsDim].[SecondColor].[All]) }), [ColorsDim].[PrimeColor].[PrimeColor].AllMember,
[ColorsDim].[SecondColor])) DIMENSION PROPERTIES PARENT_UNIQUE_NAME
,HIERARCHY_UNIQUE_NAME ON COLUMNS
,NON EMPTY Hierarchize({DrilldownMember({
[ColorsDim].[Color_id].[All] },,, INCLUDE_CALC_MEMBERS) }) DIMENSION PROPERTIES
PARENT_UNIQUE_NAME
,HIERARCHY_UNIQUE_NAME ON ROWS FROM [Model]
WHERE ([Measures].[Number of records in ColorDim]) CELL PROPERTIES VALUE
,FORMAT_STRING
,BACK_COLOR
,FORE_COLOR
,FONT_FLAGS
Error
Query Preparation failed.
Additional information
The query cannot be prepared: The query must have at least one axis. The first axis of the query should not have mulitple hierarchies, nor should it reference any dimension other than the measures dimension..
Parameter name: mdx (MDXQueryGenerator)
The following query shows the desired output:
Select non empty
[ColorsDim].[PrimeColor].children *
[ColorsDim].[SecondColor].children
on 0
, non empty
[ColorsDim].[Color_id].children
on 1
from [model]
where [Measures].[Number of records in ColorDim];
The measure in the query is a count of rows for that particular dimension