I inherited some mdx code which uses calculated members and the sum function. I need to make a new member using SUM but and OR (union?) set. I have tried various syntaxes but they all error.
I have code as below:
-- 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
The set inside the last sum function doesnt work, it returns #Error.
Does anyone know how to use a unioned set as the argument to the SUM function in mdx?
Thanks
Your problem basicly deals with the concepts of dimensionality and hierarchility
Try this
sum( { ([as_of_month] * [Incident Details].[Is SI].[Is SI][Impact].[Impact].defaultmember[Non Compliance].[Non Compliance Type].defaultmember), ([as_of_month] * [Incident Details].[Is SI].defaultmember*[Impact].[Impact].&[3]*[Non Compliance].[Non Compliance Type].&[Major non-compliance]) } , [Measures].[Environment Impact Count])
Edit: Includes explanation on how and why the above query works. In your problem you have two sets that have diffrent hierarchies in them. So you have to balance them. Lets take a look at your first set
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.
Next I encapsulaed them in "()" to indicate that they are a tuple of a larger Set.Then both these tuples are encapsulated in "{}" like this "{(tuple1),(tuple2)}"