获得的对象类型:Microsoft.AnalysisServices.AdomdClient.CellSet

Obtained object of type: Microsoft.AnalysisServices.AdomdClient.CellSet

我在 SSMS 2012 中 运行 这个查询

SELECT YTD([Date].[Calendar].[Month].&[2003])ON 0 FROM [Adventure Works];

我遇到了这个错误

Executing the query ... Obtained object of type: Microsoft.AnalysisServices.AdomdClient.CellSet Formatting. Cell set consists of 1 rows and 0 columns. Done formatting. Execution complete

我想 select 在 Cube 和 aginst 的最后十二个月中展示一些措施。

编辑 1:

当我尝试针对它显示的其中一项措施启动它时 null

SELECT YTD([Date].[Calendar].[Month].&[2003].[8])ON 0 ,
[Measures].[Internet Sales Amount] on 1
FROM [Adventure Works];

输出为:

我不足的地方。有人可以将我重定向到正确的方向

让我们先看看 YTD 文档 - 它需要成员表达式。您指定了 [Date].[Calendar].[Month].&[2003] - 这很奇怪,因为我认为 Year = 2003,而不是月份。无论如何,如果你想得到最后 12 个月,你应该尝试

select
{
   [Measures].[Total Sales] // for example
} on 0,
{
   Descendants(
               Ancestors(
                          Tail(EXISTING [Date].[Calendar].[Day].members,1).Item(0),
                          [Date].[Calendar].[Year]
                        ) // end ancestors
            ,[Date].[Calendar].[Month]
              ) // end descendants

 }
 on 1
from [YourCube]

现在稍微解释一下。 Tail(EXISTING [Date].[Calendar].[Day].members,1).Item(0) 为您提供多维数据集中存在的最后日期 Calendar dimensions。您需要几个月的时间,所以还剩下两个步骤:

  • 获取此日期的年份
  • 获取多维数据集层次结构中存在的今年的月份

Ancestors这里用来获取Year成员(第二个参数[Date].[Calendar].[Year])。现在我们已经转到年级别,所以我们准备使用 Descendants 函数获取所有月份,它给出与 [年] 相关的级别的所有成员,这里我们指定 [月份]。请同时检查列出的函数 MSDN 文档

试试这个:

SELECT 
  [Measures].[Internet Sales Amount] ON 0
 ,YTD([Date].[Calendar].[Date].&[20070114]) ON 1
FROM [Adventure Works];

它 return 是使用我们指定的水平即天数的年初至今:

然后我们可以像这样使用自定义度量来汇总以上内容:

WITH 
  MEMBER [Date].[Calendar].[YTDtotalTo14jan] AS 
    Aggregate(YTD([Date].[Calendar].[Date].&[20070114])) 
SELECT 
  [Measures].[Internet Sales Amount] ON 0
 ,[Date].[Calendar].[YTDtotalTo14jan] ON 1
FROM [Adventure Works];

看来你选了一个糟糕的 2003 年!

到 return 最近 12 个月我会使用 Tail 函数:

SELECT 
  {} ON 0 //<<add whatever measures you like in here
 ,Tail
  (
    [Date].[Calendar].[Month]
   ,12
  ) ON 1
FROM [Adventure Works];

p.s。这在我的 SSMS:

中运行良好
SELECT YTD([Date].[Calendar].[Month].&[2003])ON 0 FROM [Adventure Works];

这不是错误消息...

Executing the query ... Obtained object of type: Microsoft.AnalysisServices.AdomdClient.CellSet Formatting. Cell set consists of 1 rows and 0 columns. Done formatting. Execution complete