Mdx使用member属性作为strtomember的参数 [英] Mdx Using a member property as an argument for a strtomember

查看:170
本文介绍了Mdx使用member属性作为strtomember的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个多维数据集,该多维数据集具有两个日期维度,具有相同的结构,但是度量的行为不同:一个度量停留日期,另一个度量保留日期.因此,我需要创建一个集合,该集合将隔离在特定日期之前进行的所有保留,直到该特定日期之前的一年为止.我需要动态设置该集合,以便它在停留日期更改时发生变化...

I'm working on a cube that has two date dimensions, with the same structure, but measuring different behaviours: one measures the stay date, and the other one the reservation date. So I need to create a set that will isolate all reservations made for a specific date, until 1 year prior that specific date. I need the set to be dynamic, so it changes when the stay date changes...

现在,我正在全神贯注地试图理解为什么它能正常工作:

Now, I am blowing my mind off trying to undertand why this works fine:

SET [D365] AS {NULL: [Creation Date].[Calendar].[Day].&[20131023].lag(365)}

但这不是:

SET [D365] AS {null:strtomember("[Creation Date].[Calendar].[Day].&["+ [Business Date].[Calendar].currentmember.properties("Key")+"]").lag(365)}

何时

MEMBER [Measures].[Arg] as [Business Date].[Calendar].currentmember.properties("Key")

返回值:20131023

returns : 20131023

MEMBER [Measures].[Arg2] as "[Creation Date].[Calendar].[Day].&["+[Business Date].[Calendar].currentmember.properties("Key")+"].lag(365)"

返回[创建日期].[日历].[天].& [20131023] .lag(365)

returns [Creation Date].[Calendar].[Day].&[20131023].lag(365)

我也尝试在参数前使用cstr和format("yyyyMMdd"),但无济于事...

I've also tried to use cstr and format ("yyyyMMdd") before the argument, but to no avail...

真的,我的想法用光了... :)

Really, I am running out of ideas... :)

非常感谢您的帮助.

推荐答案

问题在于,在对WHERE子句求值之后但在查询的行和列之前,对WITH子句中的集进行求值,而对子句中的成员定义进行求值. WITH子句考虑了上下文(当前行/列的位置),因为每次发现它们出现在一个轴上时都会对其定义进行评估.这意味着在定义集合时,[Business Date].[Calendar].currentmember可能是所有成员(至少如果将[Business Date].[Calendar]层次结构放在行或列上而不是在WHERE子句中).因此,您可以将集合定义用作成员定义的子表达式或行或列集的子表达式,但是在命名集合定义中使用它是没有用的.

The problem is that sets in the WITH clause are evaluated after the evaluation of the WHERE clause but before the rows and columns of the query, while members definitions in the WITH clause take the context (current row/column position) into account, as their definition is evaluated each time they are found to appear on one of the axes. This means that [Business Date].[Calendar].currentmember probably is the all member when the set is defined (at least if you put the [Business Date].[Calendar] hierarchy on the rows or columns and not in the WHERE clause). Thus, you can use your set definition as a sub expression of a member definition or as a sub expression of the rows or columns set, but it is not useful to use it in a named set definition.

BTW:如果您需要一个引用表单将一个日期维度引用到另一个日期维度,并且它们具有相同的结构(如果它们是基于同一维度对象的角色扮演维度,则应具有相同的结构),则可以使用 LinkMember 并避免使用StrToMember.

BTW: If you need a reference form one date dimension to the other date dimension, and these have the same structure, which they should have if they are role playing dimensions based on the same dimension object, you can use LinkMember and avoid StrToMember.

这篇关于Mdx使用member属性作为strtomember的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆