[英]Calculate maximum value for a measure column without using dimension in mdx query
I would like to calculate maximum value for a measure column without using dimension in mdx query. 我想在不使用mdx查询中的维的情况下计算度量列的最大值。 I tried the following query to achieve this.
我尝试了以下查询来实现这一目标。
WITH MEMBER [Measures].[Max key] AS
Max([Internet Sales Amount].Members,[Internet Sales Amount].currentmember.MEMBER_KEY)
SELECT {[Measures].[Max key]} on COLUMNS
FROM [Adventure Works]
But I got the error in result. 但是我得到了错误的结果。
Can anyone suggest me how to achieve my requirement using mdx query? 谁能建议我如何使用mdx查询达到我的要求?
You've written this: 您已经写了这个:
WITH
MEMBER [Measures].[Max key] AS
Max
(
[Internet Sales Amount].MEMBERS
,[Internet Sales Amount].CurrentMember.Member_Key
)
SELECT
{[Measures].[Max key]} ON COLUMNS
FROM [Adventure Works];
[Internet Sales Amount]
is a measure and therefore a numeric expression so you cannot apply the functions MEMBERS
or CurrentMember
. [Internet Sales Amount]
是一个度量,因此是一个数字表达式,因此您无法应用MEMBERS
或CurrentMember
函数。 [Internet Sales Amount]
will not even have keys - so why are you trying to find a max key? [Internet Sales Amount]
甚至都没有密钥-那么为什么要尝试找到最大密钥?
Max
is defined here: https://docs.microsoft.com/en-us/sql/mdx/max-mdx Max
在此处定义: https : //docs.microsoft.com/zh-cn/sql/mdx/max-mdx
You have no choice but to include a set for the max to work over: 您别无选择,只能包括一组最大的工作量:
Max( Set_Expression [ , Numeric_Expression ] )
Max(Set_Expression [,Numeric_Expression])
This is a valid use of max: 这是max的有效用法:
WITH
MEMBER [Measures].[Max Sales] AS
Max
(
[Product].[Category].[Category]
,[Internet Sales Amount]
)
SELECT
[Product].[Category].[Category] ON ROWS
,{
[Internet Sales Amount]
,[Measures].[Max Sales]
} ON COLUMNS
FROM [Adventure Works];
It returns this: 它返回以下内容:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.