MDX Order排序

Order基础用法

Numeric expression syntax
Order(Set_ExpressionNumeric_Expression 
[ , { ASC | DESC | BASC | BDESC } ] )

String expression syntax
Order(Set_ExpressionString_Expression 
[ , { ASC | DESC | BASC | BDESC } ] )

例一:对数据排序

select [Measures].[Unit Amount] on 0,
order([Dim No Of Horses].[Horses Group Code].[Horses Group Code], --Set_Expression
[Measures].[Unit Amount], --Numeric_Expression 
asc ) on 1
from PNLDB_Cube

例二:对维度排序

SELECT
[Measures].[Unit Amount HK] ON COLUMNS,
Order(
  {[Code Race Date].[Month Number Of Season].[Month Number Of Season]}
  ,StrToValue([Code Race Date].[Month Number Of Season].currentmember.name), --StrToValue函数将String转换成Int
    BASC
) ON ROWS
from [PNLDB_Cube];

 

Order二次排序:

with

member Measures.CurYearProfit as
 (iif("1"='0',[Measures].[Trading Profit HK],[Measures].[Trading Profit]),StrToMember('[Code Race Date].[Season Year].&['+"2009"+']'))
member Measures.CurYearUnitAmount as
 (iif("1"='0',[Measures].[Unit Amount HK],[Measures].[Unit Amount]),StrToMember('[Code Race Date].[Season Year].&['+"2009"+']'))

member Measures.CurYearNoOfRaces as
 ([Measures].[NoOfRaces],StrToMember('[Code Race Date].[Season Year].&['+"2009"+']'))

SET OrderedTrack AS Order
   ([Code Track].[Track Name].[Track Name],
   iif(Measures.CurYearUnitAmount>0,Measures.CurYearProfit/Measures.CurYearUnitAmount+1,0),  asc)
member measures.roi as
iif(Measures.CurYearUnitAmount>0,Measures.CurYearProfit/Measures.CurYearUnitAmount+1,null)
select {measures.roi,

 measures.CurYearProfit,measures.CurYearUnitAmount
 ,Measures.CurYearNoOfRaces} on 0,
NON EMPTY{
Order(OrderedTrack---------------------------------------------------------------------------------已用Order排序的Set
,iif(Measures.CurYearNoOfRaces>0,1,0), bdesc)-----------------------------------------------------再经Order的二次排序
} on 1
FROM [PNLDB_Cube]

你可能感兴趣的:(order)