3

I am relatively new to this depth of MDX, but here is my dilemma. My goal is to implement a calculated member using a .Net Stored Procedure. The calculation (XIRR) will be based on a set of cash flow dates and cash flow amounts. Ideally this would be a calculation in my cube that is available as a measure to Excel/Browser users.

So to start simple I am just trying to implement my own COUNT calculated member/measure (not even using .Net) to say count the # of members in a given dimensions based on the current context. So lets say I have a dimensions Customer with a Customer Id Key. And let's say there are a total of 100 customers in my database. So Count(Customer.CustomerId.AllMembers) would be 100. Now when you start using the browser and say filter on Customer.CustomerId.&1, Customer.CustomerId.&2 (customer id 1 and 2) I would expect my count calculated member to return 2 but it returns the total 100 count. I have tried using exists. I am sure there is something that I am just fundamentally not understanding yet.

Hopefully this makes sense, would hugely appreciate any help from someone that has a good understanding of SSAS/MDX and calculations. Thanks in advance.

Marty

4

1 回答 1

2

您可能在这里遇到一些问题,当我尝试做类似的事情时,我就遇到了。

您的计算成员不尊重客户子选择,这是正常的。理论上,您要做的是创建一个动态集,然后在计算成员中使用它来强制在您的过滤器创建的子立方体的上下文中评估维度计数。Mosha在这里有一篇很好的文章:http: //sqlblog.com/blogs/mosha/archive/2007/08/25/mdx-in-katmai-dynamic-named-sets.aspx

所以你最终会得到类似的东西:

CREATE DYNAMIC SET CurrentCube.Customers AS
EXISTING(Customer.CustomerId.CHILDREN);

CREATE MEMBER CurrentCube.Measures.CustomerCount AS
Customers.COUNT

现在你将遇到的真正问题是 SSAS https://connect.microsoft.com/SQLServer/feedback/details/484865/calcuated-member-with-a-reference-to-dynamic-named-set-kills中的一个错误-the-cubes-performance,所以上面的代码可能会在本地正常工作,但会杀死生产多维数据集。这对我来说是一次令人兴奋的学习经历。

看看你是否可以得到任何解决方法,我做不到。

我能够得到我想要的东西,但是我必须创建查询范围的动态集作为 MDX 查询的一部分,我无法将它创建为多维数据集对象:

WITH DYNAMIC SET Customers AS
EXISTING(Customer.CustomerId.CHILDREN);

MEMBER Measures.CustomerCount AS
Customers.COUNT

SELECT
Measures.CustomerCount 
ON COLUMNS
FROM [Cube]
WHERE Customer.CustomerId.&[1]

让我们知道您的身体情况如何。

于 2013-07-19T13:35:08.927 回答