【问题标题】:MDX openingperiod, closingperiod and sum(measure) return the same valueMDX openingperiod、closestperiod 和 sum(measure) 返回相同的值
【发布时间】:2019-08-26 09:58:41
【问题描述】:

在我们的多维数据集中,我们希望在一个月的开始和结束时对商品数量及其价值进行概览。所以我想使用MDX表达式openingperiod()closingperiod(),他们应该提供这些指标。

在 Visual Studio 中,我们有以下代码(仅适用于 openingperiod(),因为 closingperiod() 具有相同的语法)

(OPENINGPERIOD
(
[Date Booking].[Month].[Month],
[Date Booking].[Month].currentmember
), 
[Measures].[AT Amount])

openingperiod()closingpeiod() 的结果与度量 [AT Amount] = sum(Amount) 的结果相同

如文档和示例所示,我预计会出现三种不同的结果。然而,所有三个结果都是相同的。

咨询页面:

https://docs.microsoft.com/en-us/sql/mdx/openingperiod-mdx?view=sql-server-2017

https://www.sqlservercentral.com/steps/stairway-to-mdx-level-12-mdx-timedate-series-functions-openingperiod-and-closingperiod-functions

【问题讨论】:

  • 您应该在时间维度[Date Booking].[this should be your hierarchy name] 之后使用“层次结构”。此外,正如 Mike 在答案中强调的那样,第一个参数应该是第二个参数的“子级别”(即,如果你想要一个月的第一个日期,你需要有日期和月份)。您可以编辑查询以添加完整的时间维度(即[Date Booking]),包括其级别和层次结构

标签: visual-studio ssas mdx cube


【解决方案1】:

将您的代码与示例进行比较,我怀疑您正在尝试将此技术用于单层的层次结构。

该示例适用于多级层次结构年/学期/季度/月/日期。在这种情况下,当使用 Month 级别对度量进行切片时,CURRENTMEMBER 属性会返回每个 Month 成员,该成员用于首先返回 Date 级别的子成员(在 OPENINGPERIOD 的第一个参数中指定)。

使用您的代码,CURRENTMEMBER 属性返回每个 Month 成员,该成员在 Month 级别应用,因此它将为 OPENINGPERIOD 或 CLOSINGPERIOD 返回相同的 Month 成员(或有效地为 SUM 使用相同的 Month 成员)。

我将构建一个日历层次结构,其中日期级别低于月份级别(其他级别是可选的),然后我会将您的代码编辑为:

(OPENINGPERIOD
(
[Date Booking].[Calendar].[Date],
[Date Booking].[Calendar].currentmember
), 
[Measures].[AT Amount])

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-11
    相关资源
    最近更新 更多