0
votes

I need some help with MDX query which returns the count of leaves nodes for a selected node.

Query1 :

Select { {[Dimension1].&[Member1]},{Descendants({[Dimension1].&[Member1]},,LEAVES)} } Dimension Properties [Parent_Unique_Name] On Columns From RepCube Where ({[attribute1].&[attrmember1],[attribute1].&[attrmember1]},([dimension2].&[1],[dimension3].&[1]))

Query2 :

With MEMBER [Dimension1].[3] AS 'COUNT({{[Dimension1].&[Member1]},{Descendants({[Dimension1].&[Member1]},,LEAVES)}}, EXCLUDEEMPTY)' SELECT {[Dimension1].[3]} ON 0 FROM RepCube Where ({[attribute1].&[attrmember1],[attribute1].&[attrmember1]},([dimension2].&[1],[dimension3].&[1]))

The count query Query2 should give the same count as query1 resultset count. But it is not. Here attribute1 belong to Dimension1 only. My assumption is that because attribute1 belong to Dimension1, count is not giving correct result. But the first query Query 1 is filtering the results correctly.

Please help me in fixing the second query to give the same count as Query1.

1
Use existing in the second query COUNT(existing {{[Dimension1].&[Member1]},{Descendants({[Dimension1].&[Member1]},,LEAVES)}}, EXCLUDEEMPTY)MoazRub
Thanks a lot, I searched for it a lot...Sudi

1 Answers

1
votes

You need to use existing keyword to force your calcuated member to evaluate within your where clause. Use this

COUNT(existing {{[Dimension1].&[Member1]},{Descendants({[Dimension1].&[Member1]},,LEAVES)}}, EXCLUDEEMPTY)