MDX 计算成员 SUM 与 OR
MDX Calculated member SUM with OR
我继承了一些使用计算成员和求和函数的 mdx 代码。我需要使用 SUM but 和 OR(union?)集创建一个新成员。我尝试了各种语法,但它们都出错了。
我的代码如下:
-- uses this date filter
set [as_of_month] as {strtomember("[Date].[Year - Month].[Month].&[" + cstr(format(cdate("Jul 2019"),"yyyy-MM")) + "-01T00:00:00]")}
-- member 1
member [SIONLY_MTH] as sum([as_of_month] * [Incident Details].[Is SI].[Is SI], [Measures].[Environment Impact Count])
-- member 2
member [MajorNC_Month] as sum([as_of_month] *
[Impact].[Impact].&[3] *
[Non Compliance].[Non Compliance Type].&[Major non-compliance],
[Measures].[Non Compliance Count]) + 0
-- I need a new member which is an OR of the previous 2, ie, count of
-- SI_ONLYMONTH or [MajorNC_Month] filtered by [as_of_month]
member [LegalSI_EnvSI_Month] as SUM([as_of_month] * {[Incident Details].[Is SI].[Is SI] , [Non Compliance].[Non Compliance Type].&[Major non-compliance]}
, [Measures].[Environment Impact Count]) + 0
最后一个 sum 函数中的设置不起作用,它 returns #Error.
有谁知道如何使用联合集作为 mdx 中 SUM 函数的参数?
谢谢
你的问题基本上涉及维度和层次的概念
试试这个
总和(
{
([as_of_month] * [事件详情].[是 SI].[是 SI][影响].[影响].defaultmember[不合规].[不合规类型].defaultmember),
([as_of_month] * [事件详情].[是 SI].defaultmember*[影响].[影响].&[3]*[不合规].[不合规类型].&[重大不合规遵守])
}
,
[措施].[环境影响计数])
编辑:包括对上述查询的工作原理和原因的解释。
在您的问题中,您有两组具有不同的层次结构。所以你必须平衡它们。让我们来看看你的第一组
sum([as_of_month] * [Incident Details].[Is SI].[Is SI],
[Measures].[Environment Impact Count])
This doesnt explicitly include "[Impact].[Impact]" however before executing SSAS takes the liberty to include [Impact].[Impact].defaultmember in the query. Based on this fact I balanced both of your sets by expicitly including the default members of attribute hierarchies that were orignally not part of your Set.
接下来我将它们封装在“()”中以表明它们是一个更大的元组Set.Then这两个元组都封装在“{}”中,如下所示“{(tuple1),(tuple2) }"
我继承了一些使用计算成员和求和函数的 mdx 代码。我需要使用 SUM but 和 OR(union?)集创建一个新成员。我尝试了各种语法,但它们都出错了。
我的代码如下:
-- uses this date filter
set [as_of_month] as {strtomember("[Date].[Year - Month].[Month].&[" + cstr(format(cdate("Jul 2019"),"yyyy-MM")) + "-01T00:00:00]")}
-- member 1
member [SIONLY_MTH] as sum([as_of_month] * [Incident Details].[Is SI].[Is SI], [Measures].[Environment Impact Count])
-- member 2
member [MajorNC_Month] as sum([as_of_month] *
[Impact].[Impact].&[3] *
[Non Compliance].[Non Compliance Type].&[Major non-compliance],
[Measures].[Non Compliance Count]) + 0
-- I need a new member which is an OR of the previous 2, ie, count of
-- SI_ONLYMONTH or [MajorNC_Month] filtered by [as_of_month]
member [LegalSI_EnvSI_Month] as SUM([as_of_month] * {[Incident Details].[Is SI].[Is SI] , [Non Compliance].[Non Compliance Type].&[Major non-compliance]}
, [Measures].[Environment Impact Count]) + 0
最后一个 sum 函数中的设置不起作用,它 returns #Error.
有谁知道如何使用联合集作为 mdx 中 SUM 函数的参数?
谢谢
你的问题基本上涉及维度和层次的概念
试试这个
总和( { ([as_of_month] * [事件详情].[是 SI].[是 SI][影响].[影响].defaultmember[不合规].[不合规类型].defaultmember), ([as_of_month] * [事件详情].[是 SI].defaultmember*[影响].[影响].&[3]*[不合规].[不合规类型].&[重大不合规遵守]) } , [措施].[环境影响计数])
编辑:包括对上述查询的工作原理和原因的解释。 在您的问题中,您有两组具有不同的层次结构。所以你必须平衡它们。让我们来看看你的第一组
sum([as_of_month] * [Incident Details].[Is SI].[Is SI], [Measures].[Environment Impact Count]) This doesnt explicitly include "[Impact].[Impact]" however before executing SSAS takes the liberty to include [Impact].[Impact].defaultmember in the query. Based on this fact I balanced both of your sets by expicitly including the default members of attribute hierarchies that were orignally not part of your Set.
接下来我将它们封装在“()”中以表明它们是一个更大的元组Set.Then这两个元组都封装在“{}”中,如下所示“{(tuple1),(tuple2) }"