使用RANK / ORDER编辑,建议的更改如下:
当前我返回所有销售产品的供应商的价格总和。
我想要的将返回产品名称,并返回对于每个产品具有相同产品的行具有最高最高价格的行的价格。
代码:
--Find the maximum price for each product offered in Madison
WITH MEMBER [Measures].[Max Value] AS MAX([Measures].[Price])
SELECT NON EMPTY {
[Measures].[Max Value]} ON 0,
NON EMPTY {
([Tb Product].[Name].[Name] ) } ON ROWS
FROM [DS715]
WHERE ([Tb Supplier].[City].&[Madison])
编辑:
WITH MEMBER [Measures].[Max Price RANK] AS
RANK( ([Tb Product].[Name].currentmember),
ORDER( ([Tb Product].[Name].currentmember), [Measures].[Price - Tb Transactions], BDESC) )
SELECT
NON EMPTY {
[Measures].[Price - Tb Transactions] } ON COLUMNS,
NON EMPTY {
filter([Tb Product].[Name].[Name], [Measures].[Max Price RANK] <2 )} ON ROWS
FROM [DS715]
WHERE ( [Tb Supplier].[City].&[Madison] )
现在每行仅一行,但数量很大
select
{
[Measures].[Internet Sales Amount]
}
on columns,
non empty
([Product].[Category].[Category],[Product].[Subcategory].[Subcategory])
on rows
from
[Adventure Works]
现在让我们修改查询以限制为具有最大Internet Sale的成员
WITH MEMBER [Measures].[Internet Sales Amount Rank] AS RANK( ([Product].[Category].currentmember,[Product].[Subcategory].CurrentMember), ORDER( ([Product].[Category].currentmember,[Product].[Subcategory].[Subcategory].Members) , [Measures].[Internet Sales Amount], BDESC) ) select non empty [Measures].[Internet Sales Amount] on columns, non empty ([Product].[Category].[Category],filter([Product].[Subcategory].[Subcategory],[Measures].[Internet Sales Amount Rank]<2)) on rows from [Adventure Works]
结果