我要UNION
以下MDX
查询。对于这两个查询,同一日期范围内的度量和维不同。请帮助我摆脱困境。
SELECT NON EMPTY { [Measures].[Number of es2] } ON COLUMNS,
NON EMPTY { ([Date].[Year].[Year].ALLMEMBERS * [Date].[Month].[Month].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION,
MEMBER_UNIQUE_NAME ON ROWS FROM ( SELECT ( [Date].[Date Hierarchy].[Date].&[20170101] : [Date].[Date Hierarchy].[Date].&[20180101] ) ON COLUMNS
FROM ( SELECT ( { [PracHistory].[Name].&[In] } ) ON COLUMNS FROM [Cube]))
WHERE ( [PracHistory].[Name].&[In] )
SELECT NON EMPTY { [Measures].[Number of es1] } ON COLUMNS,
NON EMPTY { ([Date].[Year].[Year].ALLMEMBERS * [Date].[Month].[Month].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION,
MEMBER_UNIQUE_NAME ON ROWS FROM ( SELECT ( [Date].[Date Hierarchy].[Date].&[20170101] : [Date].[Date Hierarchy].[Date].&[20180101] ) ON COLUMNS
FROM ( SELECT ( { [Prac].[Pra atus].&[ We] } ) ON COLUMNS FROM [Cube]))
WHERE ( [Prac].[Pra atus].&[ We] )
答案 0 :(得分:-1)
MDX不支持联合,但是周围没有。
1)您可以编写查询,以在列“ es2”的最前面显示“ Pra atus”和“ In”所有值。然后,它将为“ Pra atus”的“ we”值和“ Name”的所有值显示“ es1”。列将并排。查询将如下所示。所有值表示默认值。
SELECT NON EMPTY
{
([Measures].[Number of es2],[PracHistory].[Name].&[In],[Prac].[Pra atus].[All]),
([Measures].[Number of es1],[PracHistory].[Name].[All],[Prac].[Pra atus].&[ We])
} ON COLUMNS,
NON EMPTY { ([Date].[Year].[Year] * [Date].[Month].[Month] ) } ON ROWS
FROM [Cube]
WHERE ( [Date].[Date Hierarchy].[Date].&[20170101] : [Date].[Date Hierarchy].[Date].&[20180101] )
以上样本
SELECT NON EMPTY
{
([Measures].[Internet Sales Amount],[Product].[Category].&[1],[Customer].[Country].[All]),
([Measures].[Internet Order Quantity],[Product].[Category].[All],[Customer].[Country].&[United States])
} ON COLUMNS,
non empty
{ ([Date].[Calendar Year].[Calendar Year], [Date].[Calendar Quarter of Year].[Calendar Quarter of Year]) }
ON ROWS
FROM [Adventure Works]
WHERE ([Date].[Date].&[20130101]:[Date].[Date].&[20140101] )
2)现在,如果要使其显示在单个列中,以模拟SQL Union的行为,则需要一个计算后的量度,该量度将从这两个量度之一中选择值。但是请注意,除了在行日期上,您还将在行上看到“名称”和“ Pra atus”。该查询将如下所示。
with member [Measures].[Number of esunion]
as
case
when
[Product].[Category].currentmember is [Product].[Category].defaultmember then [Measures].[Internet Order Quantity]
when
[Customer].[Country].currentmember is [Customer].[Country].defaultmember then [Measures].[Internet Sales Amount]
else null
end
SELECT NON EMPTY
{
[Measures].[Number of esunion]
} ON COLUMNS,
non empty
{
([PracHistory].[Name].&[In],[Prac].[Pra atus].[All], [Date].[Year].[Year] , [Date].[Month].[Month]) ,
([PracHistory].[Name].[All],[Prac].[Pra atus].&[ We],[Date].[Year].[Year] , [Date].[Month].[Month])
}
ON ROWS
FROM [Cube]
WHERE ([Date].[Date Hierarchy].[Date].&[20170101] : [Date].[Date Hierarchy].[Date].&[20180101] )
以上样本
with member [Measures].[Number of esunion]
as
case
when
[Product].[Category].currentmember is [Product].[Category].defaultmember then [Measures].[Internet Order Quantity]
when
[Customer].[Country].currentmember is [Customer].[Country].defaultmember then [Measures].[Internet Sales Amount]
else null
end
SELECT NON EMPTY
{
[Measures].[Number of esunion]
} ON COLUMNS,
non empty
{
([Product].[Category].&[1],[Customer].[Country].[All],[Date].[Calendar Year].[Calendar Year], [Date].[Calendar Quarter of Year].[Calendar Quarter of Year]) ,
([Product].[Category].[All],[Customer].[Country].&[United States],[Date].[Calendar Year].[Calendar Year], [Date].[Calendar Quarter of Year].[Calendar Quarter of Year])
}
ON ROWS
FROM [Adventure Works]
WHERE ([Date].[Date].&[20130101]:[Date].[Date].&[20140101] )