Quantcast
Channel: SQLServerCentral » Data Warehousing » Analysis Services » Latest topics
Viewing all articles
Browse latest Browse all 1341

How do you filter a calculation by an existing hierarchy?

$
0
0
I'm trying to figure out the proper MDX for a calculated member so that it only does the calculation on members of a specific hierarchy when it is a certain value. I thought I had it, but I am consistently getting the dreaded 1.#INF (divide by zero) even though I thought I trapped it properly in the beginning:[code="sql"]WITH MEMBER [Measures].[MyNewCalculatedMember] as IIF([Measures].[ExistingMeasure]=0, null , SUM( EXISTING ([Dimension].[HierarchyRoot].[HierarchyLeaf].MEMBERS, IIF([Dimension].[HierarchyRoot].CURRENTMEMBER is [Dimension].[HierarchyRoot].[HierarchyLeaf].&[2], [Measures].[OtherMeasure] / [Measures].[ExistingMeasure], null) , IIF([Dimension].[HierarchyRoot].CURRENTMEMBER.PARENT is [Dimension].[HierarchyRoot].[HierarchyLeaf].&[2], [Measures].[OtherMeasure] / [Measures].[ExistingMeasure], null)))* 1000)[/code]I'm pretty sure I'm totally hosing this up as I'm a complete MDX noobie, but this seems to be close. If I filter down to the leaf level, I get what I expect with values or nulls if the denominator is null.When I roll it up to the parent of the hierarchy, I get the dreaded 1.#INF.Isn't there an easier way to do this with something like Ancestor or something?Any help would be greatly appreciated!

Viewing all articles
Browse latest Browse all 1341

Trending Articles