【发布时间】:2021-02-20 05:14:12
【问题描述】:
我需要一些 mdx 帮助。
立方体详情:
Measures.Users -> 对用户的不同计数。
我想找到这个查询的 mdx 等效项:
Select a.shopId , Month(TransactionDate) Month_Transaction,
Year(TransactionDate) Year_Transaction,
count(distinct b.UserID) UniqueUserCount
FROM [dbo].[shop] a
JOIN users b ON a.UserID = b.UserID
where TransactionDate >= '2018-01-01'
Group by a.shopId ,Month(TransactionDate), Year(TransactionDate)
这是我迄今为止所拥有的,无论日期如何,它都会产生唯一计数。我想要日期范围内的唯一计数。请让我知道如何实现这一目标?
SELECT {
[Date].[Month].&[2020]&[2020-Q3]&[2020-09],
[Date].[Month].&[2020]&[2020-Q4]&[2020-10],
[Date].[Month].&[2020]&[2020-Q4]&[2020-11],
[Date].[Month].&[2020]&[2020-Q4]&[2020-12]
} ON COLUMNS, NON EMPTY
{
[ShopLocations].[Hierarchy].[Shop]
} ON ROWS
FROM [ShopperCube]
where (Measures.Users)
【问题讨论】:
-
内置的不同计数度量提供了最大的灵活性。听起来您已经有一个 Measure.Users 了?用户的度量组是否与您的日期和商店位置维度相关联?
-
有没有办法使用计算列来做到这一点?我认为用户度量组未连接到日期。
-
应该是可以连接的。我将在多对多革命论文中应用 Distinct Count 模式,以获得更灵活且运行速度更快的无代码解决方案:sqlbi.com/whitepapers/many2many
-
@MikeHoney 您最初的评论帮助我解决了问题。谢谢。
-
不用担心 - 转发为答案,因为我的多巴胺命中。