比方说,我们有一个带有维度'Grocery store'的多维数据集,它有两级层次结构:
问题是 - 我如何在RDL-report的mdx查询中添加层次结构级别,以便'Tomatoes'和'Cucumbers'成员将在本地第二级'Vegetables'下移动到新的第3级。我需要在没有对Cube进行任何更改的情况下这样做,所有这些都只通过纯mdx。
当我尝试为所需的第3级构建计算集并将其与初始层次结构的其余部分一起使用时,如下所示:
WITH SET [Level 3] AS
case
when [Grocery store].[Hierarchy].[Level 2].CURRENTMEMBER = [Grocery store].[Hierarchy].&[Tomatoes] OR
[Grocery store].[Hierarchy].[Level 2].CURRENTMEMBER = [Grocery store].[Hierarchy].&[Cucumbers]
then [Grocery store].[Hierarchy].[Level 2].CURRENTMEMBER
else null end
SELECT {[Measures].[Sales]} ON COLUMNS,
CrossJoin(Hierarchize( {[Grocery store].[Hierarchy].[Level 2]}
-{[Grocery store].[Hierarchy].&[Tomatoes],
[Grocery store].[Hierarchy].&[Cucumbers]}),
[Level 3]) ON ROWS
FROM [CUBE]
我遇到一个错误,告诉我,交叉连接功能不能两次使用同一维度的“杂货店”。
答案 0 :(得分:1)
动态创建新关卡是不可能的。
不是很漂亮,但解决这个问题的一种方法是在一些不相关的维度中创建几个新的计算成员,然后交叉加入到第二级。
WITH
MEMBER [Geography].[Tomatoes] AS ([Geography].[All],[Grocery store].[Hierarchy].&[Tomatoes])
MEMBER [Geography].[Cucumbers] AS ([Geography].[All],[Grocery store].[Hierarchy].&[Cucumbers])
SET [Level 3] AS
{
[Geography].[Tomatoes],
[Geography].[Cucumbers]
}
SELECT
{[Measures].[Sales]} ON COLUMNS,
CrossJoin(
Hierarchize(
{[Grocery store].[Hierarchy].[Level 2]}
{[Grocery store].[Hierarchy].&[Tomatoes],
[Grocery store].[Hierarchy].&[Cucumbers]}
)
,[Level 3]
) ON ROWS
FROM [CUBE]