[英]How to use IsLeaf in mondrian mdx formula?
尝试在Pentaho Mondrian Cube中重新创建此公式。
IIF(ISLEAF([时间] [月] .CurrentMember)),[措施] .m1,0)
此公式已在SSAS多维数据集中使用。 需要在Pentaho Mondrian Cube中重新创建类似的公式。
IsLeaf可以在mondrian中使用吗,或者有其他替代方法吗?
在默认层次结构中,以下任何内容都可以在任意级别上运行。
如果您选择[Time].[Year]
成员,它将返回上一年的[Mesures] .m1(具有非空的m1度量并满足您的过滤条件)。
否则,它将返回去年最后一个月的度量,如果您选择[Time].[Month]
成员,则该度量将具有非空的m1度量。
虽然我认为如果您混合使用不同级别的成员(例如WITH SET time_members AS {[Time].[2017], [Time].[2017].[1]. [Time].[2017].[1].[31]}
则不会起作用WITH SET time_members AS {[Time].[2017], [Time].[2017].[1]. [Time].[2017].[1].[31]}
)
如果不需要这种通用方法,则可以简化此解决方案,并可以提高度量计算速度。
警告:查询可能会导致100%的CPU使用率(或可能不会,我不确定),从而使服务器无响应。 因此,请仔细选择您的测试环境。
免责声明:我目前没有mondrian要测试,因此以下示例很可能会出错。
Iif(
// Check if current [Time] member is the last member:
[Time].CurrentMember
IS
// Take the 0th member from the end of the set (AFAIK, mondrian sets are guaranteed to be ordered):
Tail(
// AFAIK, Level.Members returns the full set of members, disregarding query filters.
// So I use Filter function to filter members, which don't exist in context of current cell.
// It should leave only members, which (are related to current cell and satisfy filter conditions of the query).
Filter(
[Time].CurrentMember.Level.members
// If your measure is nullable, then you might want to use count measure in this condition instead of m1:
, NOT IsEmpty([Measures].m1)
)
// Number of members to get by the Tail() function:
, 1
// Return the only member of the set as a Member (not as a Set):
).Item(0)
// return if true
, [Measures].m1
// else:
, 0
)
可能有问题并需要测试的一些要点:
如果最后一个[Time]成员的m1小节为空,则如何计算小节(如果这是您的小节的有效情况)
如何在[时间]层次结构的不同级别上计算度量。
如果未在报表中明确使用[时间]维,则如何计算度量。
如果仅在切片器轴上使用[时间]维,则如何计算度量(在WHERE条件下)
如果使用受限的[Time]成员集,例如显式枚举集合文字中的成员(例如{[Time].[2006].[01], [Time].[2006].[02]}
)或通过在维度上使用Filter()函数。
如果在其他尺寸/度量上使用拟合器,则如何计算度量。
在[时间]维度的已计算成员(包括分析器生成的总计和小计)中如何计算度量。
如果从同一轴上的不同级别中选择成员,则如何计算度量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.