MDX 查询/表达式不起作用

发布于 2024-07-12 23:49:32 字数 668 浏览 5 评论 0原文

我是 MDX 表达式和查询的新手,目前正在寻找类似的内容 -

我有两个日期 'Date1' & 事实表中的“Date2”作为 DATE 维度的外键。 我需要计算 Date1 的行数 日期 2,请记住我不想计算 NULL。 我写了一个类似这样的表达式 -

WITH MEMBER [Measures].[RecordCount] AS
COUNT(FILTER([Measures].[RecordCount], IIF([Date1].[Date] <= [Date2].[Date],0,1)=1))
SELECT [Measures].[RecordCount] ON 0
FROM [MYCUBE]

上面的查询运行良好,但计数结果不正确。 我在事实表中创建了 7 行,其中 Date1 小于 Date2,但我收到的计数仍然为 0。

如有任何帮助,我们将不胜感激。 (任何参考网站对未来也有好处)

谢谢, 维内特 [电子邮件受保护]

I am new to MDX expressions and queries and I am currently looking for something like this -

I have two dates 'Date1' & 'Date2' in Fact Table as Foreign Keys to DATE dimension. I need to do a count of rows where Date1 < Date 2, keeping in account that I don't want to count NULLS. I wrote an expression something like this -

WITH MEMBER [Measures].[RecordCount] AS
COUNT(FILTER([Measures].[RecordCount], IIF([Date1].[Date] <= [Date2].[Date],0,1)=1))
SELECT [Measures].[RecordCount] ON 0
FROM [MYCUBE]

The above queries runs fine, but the count turns out to be incorrect. I created 7 rows in my fact table where Date1 is less than Date2, but still I receive the count as 0.

Any help is appreciated. (any reference sites would be good too for future)

Thanks,
Vineet
[email protected]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

难如初 2024-07-19 23:49:32

在 MDX 中您实际上无法轻松做到这一点,[RecordCount] 度量将在比较日期之前进行聚合,因此您永远不会获得有效值。

您最好在 DSV 中创建一个具有类似内容的命名计算

CASE WHEN Date1 < Date2 THEN 1 ELSE NULL END

,然后在多维数据集中创建一个度量来总结这个新列。

You can't really do this easily in MDX, the [RecordCount] measure will be aggregated up before you do the comparison of the dates, so you will never get a valid value.

You would be better to create a named calculation in your DSV that has something like

CASE WHEN Date1 < Date2 THEN 1 ELSE NULL END

and then create a measure in your cubes that sums up this new column.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文