【发布时间】:2016-10-27 21:06:22
【问题描述】:
我在 Excel 中有以下表达式可以正常工作。
=CUBESET("ThisWorkbookDataModel",
"TopCount(
[ProductBV].[Product Name].Children,10,
sum(
(
[Calendar].[Week Ending].[All].[1/6/2013]:[Calendar].[Week Ending].[All].["&TEXT($E$2,"m/d/yyyy")&"],
[ProductBV].[Moderation Status (ALL)].[All].["&$E$3&"]
),
[Measures].[Product Review Count]
)
)",
"Top 10 to date")
使用以下 DAX 公式衡量产品评论计数。
Product Review Count:=COUNTROWS(ProductBV)
但是,当我将 DAX 度量更改为使用 AVERAGE 函数(Product Avg Review)的度量时,CUBESET 函数无法正常工作。它在 CUBESET 中仍然有正确数量的项目,但是当我使用 CUBERANKEDMEMBER(1-10) 时,它没有显示按平均评分排名前 10 位的产品。
Product Avg Review:=AVERAGE(ProductBV[Rating])
下面的“工作不正常”表达式:
=CUBESET("ThisWorkbookDataModel",
"TopCount(
[ProductBV].[Product Name].Children,10,
sum(
(
[Calendar].[Week Ending].[All].[1/6/2013]:[Calendar].[Week Ending].[All].["&TEXT($E$2,"m/d/yyyy")&"],
[ProductBV].[Moderation Status (ALL)].[All].["&$E$3&"]
),
[Measures].[Product Avg Review]
)
)",
"Top 10 to date")
总而言之,我的数据很简单。我有一个数据表连接到包含我的产品名称、评级、日期和评论状态的日历表。
用户可以通过下拉菜单更改我的仪表板中的日期 ($E$2) 和审核状态 ($E$3)。
+-----------------+-------------------+------------+----------------+
| Submission Date | Moderation Status | Product ID | Overall Rating |
+-----------------+-------------------+------------+----------------+
| 10/23/2016 | APPROVED | Product 1 | 5 |
| 10/23/2016 | APPROVED | Product 2 | 5 |
| 10/23/2016 | APPROVED | Product 3 | 5 |
| 10/23/2016 | REJECTED | Product 3 | 3 |
| 10/23/2016 | REJECTED | Product 4 | 3 |
+-----------------+-------------------+------------+----------------+
谁能告诉我为什么会这样以及如何解决它?
【问题讨论】:
-
我很好奇需要使用 Excel 函数。为什么不在 PowerPivot 模型中使用 DAX 进行计算?如果您提供有关您的模型的详细信息,我们可以给您一些建议。
-
我使用 Excel 功能的原因是在仪表板上显示排名前 10 位的产品,按每周平均评分的变化量。因为我有数百种产品,所以我只希望显示前 10 名,而不是按评级变化量排序的大表。很高兴在 DAX 中完成这一切(并提供模型详细信息),但我不确定在不使用 Excel 函数的情况下这种方法将如何实现。
-
在 DAX 中,您可以轻松获得特定日期范围内前 10 种产品的平均值。如前所述,如果您提供模型和示例数据,我们可以给您一些建议。
-
哇 - 很高兴知道。什么方法最好把这个模型寄给你?需要一个小时来创建虚拟数据,因为它是客户端敏感的。谢谢!
-
只需编辑您的问题以包含这些详细信息。检查this 帖子。您还可以提供从任何云存储服务、驱动器、保管箱等下载 excel 文件的链接。
标签: excel mdx powerpivot