如何编写 MDX 语句或查询来选择上个月付款但本月尚未付款的客户?
如何编写 MDX 语句或查询来选择上个月付款但本月尚未付款的客户?我在 Microsoft SQL Server Analysis Services R 2 上设计并部署了一个数据立方体。我有一个客户维度和一个事实表。 请帮忙。
How can I write an MDX statement or query that selects the clients who paid last month but have not paid this(Current Month) month?. I have a data cube designed and deployed on Microsoft SQL Server Analysis Services R 2. I have a customer dimensions and a fact table.
Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我假设您有一个 [时间] 维度,以及一个包含客户已付款的值的度量。我认为
Filter()
函数将帮助您将所有客户端的集合减少到仅您感兴趣的客户端。SELECT {Filter({[Client].[SomeLevel] .members}, ([时间].[上个月], [测量].[任意]) > 0 AND ([时间].[本月], [测量].[任意]) = 0} ON ROWS, {[Measures].[whatever]} ON COLUMNS FROM [CubeName]
您可能很难决定使用什么来代替我写的 [Time].[ThisMonth] - 请参阅 StackOverflow 上的其他答案以选择“当前的日期。
I assume you have a [Time] dimension, and a measure that contains a value if the client has paid. I think the
Filter()
function will help you reduce a set of all clients down to just the clients that you're interested in.SELECT {Filter({[Client].[SomeLevel].members}, ([Time].[LastMonth], [Measures].[whatever]) > 0 AND ([Time].[ThisMonth], [Measures].[whatever]) = 0} ON ROWS, {[Measures].[whatever]} ON COLUMNS FROM [CubeName]
You trouble might be deciding what to use in place of where I wrote [Time].[ThisMonth] - see other answers here on StackOverflow for selecting 'current' dates.
首先,您必须确定当前月份和上个月。一种方法是使用
VBA!Date
函数计算它。因此,如果您的日期以
12/31/2014
格式存储,并假设您有一个度量Payment
和一个带有Year-Quarter-Month- 的日期维度, Date
层次结构,下面的代码可以帮助您。相反,如果您想从前端传递此“当前”值,请在
WHERE
子句中使用参数。First of all, you have to identify the current month and the last month. One way to do it is compute it using the
VBA!Date
function.So if your dates are stored in the format
12/31/2014
and assuming you have a measurePayment
and a Date dimension with aYear-Quarter-Month-Date
hierarchy, the below code can help you.If instead you would like to pass this "current" value from the front end, use a parameter in the
WHERE
clause.