ssas - 来自 AdventureWorks 的 SSAS 不同销售客户
问题描述
我目前正在尝试逐月从 Adventure Works 立方体中获得不同的回头客数量。
因此,如果客户在 2014 年 10 月和 2014 年 11 月进行了一对多的购买,那么他们将在 2014 年 11 月计算一次。
如果它们在 2014 年 10 月但不在 2014 年 11 月,则它们不会被计算在内。
如果它们不在 2014 年 10 月,但它们在 2014 年 11 月,则它们不会被计算在内。
我的查询目前如下所示:
WITH
MEMBER MEASURES.[Returning Customers] AS
DISTINCTCOUNT(
NONEMPTY(
NONEMPTY(
[Customer].[Customer].MEMBERS
, [Measures].[Sales Amount])
, {[Measures].[Sales Amount]}
* [Date].[Calendar].[Month].CURRENTMEMBER.PREVMEMBER
)
)
SELECT
{
MEASURES.[Returning Customers]
} ON COLUMNS,
[Date].[Calendar].[Month].MEMBERS ON ROWS
FROM [Adventure Works]
这显示了月份列表,但每一列都有一个#Error。我究竟做错了什么?
解决方案
双击#Error 以获取错误消息会有所帮助。但让我猜你的问题是 CurrentMember 不是 Month 级别的函数,而是 Calendar 层次结构。尝试以下操作:
WITH
MEMBER MEASURES.[Returning Customers] AS
COUNT(
NONEMPTY(
NONEMPTY(
[Customer].[Customer].[Customer].MEMBERS
, [Measures].[Sales Amount])
, ([Measures].[Sales Amount],[Date].[Calendar].CURRENTMEMBER.PREVMEMBER)
)
)
SELECT
{
MEASURES.[Returning Customers]
} ON COLUMNS,
[Date].[Calendar].[Month].MEMBERS ON ROWS
FROM [Adventure Works]
推荐阅读
- c - 为什么 curl 无法使用受密码保护的密钥?
- java - 变量仅在 while 循环内失去价值
- .net-core - 更新、创建或删除 EF Core
- javascript - 如何在 Nuxt 中使路由区分大小写
- python - 如何使用元类和命令行调用 python 类
- java - Spring boot2 抱怨 CircuitBreakerConfigurationOnMissingBean
- ios - UIImagePickerController 编辑图像 - 在顶部裁剪一些额外的图像
- node.js - 货币和间隔字段必须在此订阅的所有计划中匹配。发现区间字段不匹配
- javascript - 如何使用 MongoDB 使单选按钮自动签入编辑页面?
- svg - 在 Flutter 中绘制 SVG 并与之交互