MDX 无法将我的表达式识别为元组集?
当我有两个使用 &[Value] 语法交叉连接的成员引用时,我会收到以下错误:
Query (3, 3) 该函数需要 1 个参数的元组集表达式。使用了字符串或数字表达式。
请注意,函数
中有两个空格,就好像它试图命名一个没有名称的函数一样。我可以使用“Adventure Works DW 2008R2”示例数据库重新创建该问题。
不起作用:
SELECT
NON EMPTY
{
[Date].[Day of Month].&[1]
* [Sales Territory].[Sales Territory Country].&[Canada]
* [Measures].[Sales Amount]
}
ON COLUMNS,
NON EMPTY
{
[Product].[Product Name]
}
ON ROWS
FROM [Adventure Works]
有效:
SELECT
NON EMPTY
{
[Date].[Day of Month].&[1]
* {([Sales Territory].[Sales Territory Country].&[Canada])}
* [Measures].[Sales Amount]
}
ON COLUMNS,
NON EMPTY
{
[Product].[Product Name]
}
ON ROWS
FROM [Adventure Works]
也有效:
SELECT
NON EMPTY
{
{([Date].[Day of Month].&[1])}
* [Sales Territory].[Sales Territory Country].&[Canada]
* [Measures].[Sales Amount]
}
ON COLUMNS,
NON EMPTY
{
[Product].[Product Name]
}
ON ROWS
FROM [Adventure Works]
也有效:
SELECT
NON EMPTY
{
[Date].[Day of Month].&[1]
* [Measures].[Sales Amount]
}
ON COLUMNS,
NON EMPTY
{
[Product].[Product Name]
}
ON ROWS
FROM [Adventure Works]
也有效:
SELECT
NON EMPTY
{
[Sales Territory].[Sales Territory Country].&[Canada]
* [Measures].[Sales Amount]
}
ON COLUMNS,
NON EMPTY
{
[Product].[Product Name]
}
ON ROWS
FROM [Adventure Works]
它将我的表达式解释为什么(如果不是元组集)?我总是被这些事情绊倒,它认为它是一个字符串或数字表达式,它试图对我的元组集做什么,这真的很令人困惑。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这确实令人困惑,因为两个查询之间似乎没有太大区别。博客文章中描述了该问题:http://www.softwaremasons.com/MartinsBlog/tabid/74/EntryId/56/Is-SSAS-Too-Lenient-on-MDX-Syntax.aspx
如果您替换第一个* 运算符与 CrossJoin 函数一起使用,您会发现查询执行得很好。
* 只是以不同方式编写的 CrossJoin - 因此,如果它以一种方式工作,而另一种方式失败 - 我们可以假设问题在于 Analysis Services 引擎如何解析 * 运算符。当您添加 CrossJoin 函数时,您将显式返回一个集合,然后将其与 * 一起使用以与度量进行交叉连接,一切都很好。在您的工作示例中,您已经使用大括号显式标识了一个集合,从而为引擎提供了继续查询所需的内容 - 但是当您尝试对两个成员使用 * 时,它会失败。从技术上讲,每个成员都是一组,它应该可以工作,但是引擎没有以这种方式解析查询并且失败。
上面的博文很友善地指出问题在于 MDX 的宽大处理。它让我们无需强输入结果(即排除 {} 以将成员输入为集合)。我自己会称其为错误。 :) 如果语言允许我们在一个地方宽松,那么它在其他地方就应该保持一致。
This is indeed confusing because it appears there is not much difference between the two queries. The problem is described here in a blog post: http://www.softwaremasons.com/MartinsBlog/tabid/74/EntryId/56/Is-SSAS-Too-Lenient-on-MDX-Syntax.aspx
If you replace the first * operator with the CrossJoin function you'll find that the query executes fine.
The * is simply a CrossJoin written a different way - so if it works one way, and fails the other - we can assume that the problem is in how the Analysis Services engine is parsing the * operator. When you add in the CrossJoin function, you are explicitly returning a set which it then uses with * to crossjoin with the measure, and all is well. In your working examples, you have explicitly identified a set by using braces, thus giving the engine what it needs to proceed with the query - but when you try to use * with two members, it fails. Technically, each member is a set of one and it should work, but the engine is not parsing the query in this way and fails.
The blog post above is being kind when it says the issue is the leniency of MDX. It lets us get away without strongly typing our results (i.e. excluding the {} to type a member as a set). I would call it a bug myself. :) If the language lets us be loose in one place, it should be consistent everywhere else.
该表达式是一个单元组集(即具有作为多维数据集中一个特定成员的元组的集合。这(令人困惑地)与元组集不同。
来自 MSDN - 成员、元组和集合
至于错误消息,当您看到带有额外空格的“函数”时,它指的是查询中未应用函数的格式错误的集合或元组(因此没有函数名称可放入错误消息中) 。
例如,如果您编写了类似
EXCEPT([A].[B].[C], [D].[E].[F])
的查询,并且其中一个参数无效,你会得到一个包含“The function except...”的错误。但如果你只是有一个定义错误的集合或元组,你会得到带有两个空格的“函数”。 MSAS 的错误报告似乎很差!The expression is a single-tuple set (i.e. a set with a tuple that is one specific member in the cube. This is (confusingly) not the same as a tuple set.
From MSDN - Members, Tuples and Sets
As for the error message, when you see "The function " with extra spaces, it's referring to a malformed set or tuple in your query which doesn't have a function applied (hence there is no function name to put in the error message).
For instance, if you wrote a query like
EXCEPT([A].[B].[C], [D].[E].[F])
and one of those parameters was invalid, you'd get an error containing "The function EXCEPT...". But if you just have a badly-defined set or tuple, you get "The function " with two spaces. This seems to be poor error reporting by MSAS!