[英]How filter only the children members in MDX?
When I run this mdx query, works fine (get the children members from a hierarchy level): 当我运行此mdx查询时,工作正常(从层次结构级别获取子级成员):
select {} on columns,
[Dimension].[hierarchy].[level].children on rows
from [Cube]
But, when I add some tuple on rows, doesn't filter filter the children members (shows all the members) :S 但是,当我在行上添加一些元组时,不进行筛选过滤子成员(显示所有成员):S
select {} on columns,
[Dimension].[hierarchy].[level].children
* [Dimension2].[hierarchy2].[level2].allmembers on rows
from [Cube]
*
is a cross join - you will get the Cartesian product of [Dimension].[hierarchy].[level].children
and [Dimension2].[hierarchy2].[level2].allmembers
because they are different dimensions. *
是交叉[Dimension2].[hierarchy2].[level2].allmembers
由于它们是不同的维,因此您将获得[Dimension].[hierarchy].[level].children
和[Dimension2].[hierarchy2].[level2].allmembers
。
If they were two hierarchies from the same dimension then auto exist behaviour would limit the results eg Year2014 crossed with month should just show the months in 2014. 如果它们是来自同一维度的两个层次结构,则自动存在行为将限制结果,例如,Year2014与月相交应仅显示2014年中的月份。
Try using DESCENDANTS
function + you might not require NULLs so try the NON EMPTY
尝试使用DESCENDANTS
函数+您可能不需要NULL,因此请尝试NON EMPTY
SELECT
{} ON COLUMNS,
NON EMPTY
DESCENDANTS(
[Dimension].[hierarchy].[level].[PickAHigherUpMember],
[Dimension].[hierarchy].[PickTheLevelYouWantToDrillTo]
)
*
[Dimension2].[hierarchy2].[level2].allmembers ON ROWS
FROM [Cube]
if you look at the mdx language reference for children, you will also find another example of how to use the function with a hierarchy in stead of a member_expression. 如果查看儿童的mdx语言参考,您还将找到另一个示例,该示例说明如何将函数与层次结构一起使用,而不是member_expression。
http://msdn.microsoft.com/en-us/library/ms146018.aspx http://msdn.microsoft.com/en-us/library/ms146018.aspx
but it won't work with a hierarchy level. 但它不适用于层次结构级别。
Maybe the row expression was initialy a hierarchy that you've have changed into a level expression. 也许行表达式最初只是一个已经更改为级别表达式的层次结构。
in the following a similar working mdx with a hierarchy on rows: 在下面的类似的工作mdx中,行上具有层次结构:
select {} on 0,
[Product].[Model Name].children
*
[Geography].[Country].[All Geographies]
on 1
FROM [Adventure Works
Philip, 菲利普,
I guess you want only those rows where the children have a value on the default measure. 我猜您只想要那些子级具有默认度量值的行。 In that case you could try the following: 在这种情况下,您可以尝试以下操作:
select {} on columns,
Nonempty([Dimension].[hierarchy].[level].children
* [Dimension2].[hierarchy2].[level2].allmembers) on rows
from [Cube]
Now if, for the children, you'd need all the members from Dimension2 then you could try: 现在,如果对于孩子来说,您需要Dimension2中的所有成员,则可以尝试:
select {} on columns,
Nonempty([Dimension].[hierarchy].[level].children, [Dimension2].[hierarchy2].[level2].allmembers)
* [Dimension2].[hierarchy2].[level2].allmembers) on rows
from [Cube]
In the second case the Nonempty function takes a second parameter and the cross join is done with the result of the Nonempty function. 在第二种情况下,Nonempty函数采用第二个参数,并通过Nonempty函数的结果进行交叉联接。 For the documentation on Nonempty including the usage of the second parameter see https://docs.microsoft.com/en-us/sql/mdx/nonempty-mdx 有关Nonempty的文档(包括第二个参数的用法),请参见https://docs.microsoft.com/zh-cn/sql/mdx/nonempty-mdx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.