MDX 相当于 SQL 的 GROUP BY,用于排除重复行
我的多维数据集有一个事实表,其中包含对任何实体所做的每次修改的行。我需要的是一个将根据所选维度返回实体计数的度量。 因此,如果用户从日期维度选择月份,则度量应返回该月修改的实体数量(而不是修改数量)。
在 SQL 中,这将类似于:
SELECT EntityID, COUNT(*)
FROM FactTable
WHERE Date BETWEEN X AND Y
GROUP BY EntityID
如何在 MDX 中执行此操作?当然,这对于立方体来说是一个非常常见的场景。
My cube has a fact table that contains a row for every modification made to any entity. What I need is a measure that will return a count of the entities based on the selected dimensions.
So if the user selects a month from the date dimension then the measure should return the number of entities that were modified that month (rather than the number of modifications).
In SQL this would be something like:
SELECT EntityID, COUNT(*)
FROM FactTable
WHERE Date BETWEEN X AND Y
GROUP BY EntityID
How can you do this in MDX? Surely this would be an extremely common scenario with cubes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的 t-sql 查询相当于 mdx 查询:
在上面的查询中 [Fact rows countmeasure] 将是具有聚合公式 Count - 行数的度量
但是,如果您在按另一个维度切片时需要返回实体成员的非重复计数,则基本上有多种选择:
HTH,
赫尔沃耶·皮亚塞沃利
Your t-sql query is equivalent of mdx query:
In the above query [Fact rows count measure] would be a measure with aggregation formula Count - count of rows
However, if you need to return the distinct count of entity members when you slice by another dimension, you basically have several options:
HTH,
Hrvoje Piasevoli