我最近使用excel連接到分析服務並生成了用於查詢多維數據集的mdx代碼。代碼如下所示。該代碼還使用sql profiler進行了驗證。但是,當我去分析服務並瀏覽多維數據集並將其放入管理工作室的多維數據集中時,出現錯誤。請讓我知道,如果代碼可以修復。這段代碼正是我所需要的,因此如果有任何修改,請在多維數據集本身中進行替換。使用從數據透視表生成的mdx的問題
代碼
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
錯誤
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)
下面的查詢給出了期望的輸出:
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];
查詢中的措施是針對特定維度
你能澄清嗎?你在SSMS中使用MDX窗口嗎?你在使用Reporting Services嗎?你是在SSMS中打開一個對立方體的查詢窗口,然後編輯MDX?嘗試一個MDX窗口。 – GregGalloway
您的mdx工作正常。但是,當你瀏覽多維數據集並在其中輸入相同的代碼時,相同的mdx不起作用。 – Mutai
啊。多維數據集瀏覽器本質上是Reporting Services MDX查詢設計器。它只支持列上的措施。所以我會堅持使用MDX查詢窗口而不是多維數據集瀏覽器。 @whytheq是絕對正確的。 – GregGalloway