在SQL方面,我的数据看起来像这样:
Select f.id, f.TimeKey,t.CalendarYearMonth
from FactSubmission f
inner join DimTime t on t.TimeKey = f.TimeKey
order by f.Id asc
从MDX排序我们有下降
SELECT
NON EMPTY ORDER(
[DimTime.CalendarYearMonth].[CalendarYearMonth].Members,
[DimTime.CalendarYearMonth].CurrentMember.Properties("MEMBER_KEY"),
DESC
) ON COLUMNS
FROM [PSE_FactSubmission]
升序
1月份的日期不在任何一种排名的顶部,这表示我按FactSubmission.ID
键而不是DimTime.CalendarYearMonth
排序
这是事情应该如何运作?我想退回1月,2月,3月。
DimTime.CalendarYearMonthNum是一个包含201501,201502,201503等形式数据的列。这里尝试使用此列对CalendarYearMonth数据进行排序。
答案 0 :(得分:0)
尝试使用其他属性进行排序:
SELECT
NON EMPTY ORDER(
[DimTime.CalendarYearMonth].[CalendarYearMonth].Members,
[DimTime.CalendarYearMonth].CurrentMember.Properties("MEMBER_Value"),
DESC
) ON COLUMNS
FROM [PSE_FactSubmission];
或者这个:
SELECT
NON EMPTY ORDER(
[DimTime.CalendarYearMonth].[CalendarYearMonth].Members,
[DimTime.CalendarYearMonth].CurrentMember.MEMBERValue,
DESC
) ON COLUMNS
FROM [PSE_FactSubmission];
在上面你应该善于使用DESC
- 有时你需要通过添加B
来打破基础层次排序,即BDESC
从这里我看不到MEMBER_VALUE
:http://mondrian.pentaho.com/documentation/mdx.php
...但是有一个函数.VALUE
所以请尝试以下方法:
SELECT
NON EMPTY ORDER(
[DimTime.CalendarYearMonth].[CalendarYearMonth].Members,
[DimTime.CalendarYearMonth].CurrentMember.Value,
DESC
) ON COLUMNS
FROM [PSE_FactSubmission];
奇怪的是钥匙不起作用。如果你运行这样的东西,你会得到什么价值?
WITH MEMBER [KEYcheck] AS
[DimTime.CalendarYearMonth].CurrentMember.Properties("MEMBER_KEY")
//[DimTime.CalendarYearMonth].CurrentMember.MEMBER_KEY
//[DimTime.CalendarYearMonth].[CalendarYearMonth].CurrentMember.MEMBER_KEY
//[DimTime].CurrentMember.MEMBER_KEY
SELECT
[KEYcheck] ON 0,
[DimTime.CalendarYearMonth].[CalendarYearMonth].Members ON 1
FROM [PSE_FactSubmission];
答案 1 :(得分:0)
您正在按字母顺序排序。的˚F强> ebruary->的Ĵ强> anuary->的中号强>拱
要根据月份编号进行排序,需要有一个映射1月1日,2月2日,3月3日的字段。
如果您在立方体中有这样的列,请使用它来进行排序。如果没有创建如下的计算成员 -
WITH MEMBER Measures.CalendarMonth AS
CASE [DimTime.CalendarYearMonth].CurrentMember
WHEN [DimTime.CalendarYearMonth].&[January] THEN 1
WHEN [DimTime.CalendarYearMonth].&[February] THEN 2
WHEN [DimTime.CalendarYearMonth].&[March] THEN 3
END
SELECT
NON EMPTY ORDER(
[DimTime.CalendarYearMonth].[CalendarYearMonth].Members,
Measures.CalendarMonth,
DESC
) ON COLUMNS
FROM [PSE_FactSubmission]
编辑Andrew
with member Measures.[MonthNum] as
NonEmpty
(
[DimTime.CalendarYearMonthNum].[CalendarMonthNum].members,
([DimTime.CalendarYearMonth].[CalendarYearMonth].currentmember, Measures.foo)
).item(0).membervalue
select
non empty
order
(
[DimTime.CalendarYearMonth].[CalendarYearMonth].members,
Measures.[MonthNum],
desc
) on rows
from [PSE_FactSubmission]
编辑 - EXISTS
with member Measures.[MonthNum] as
EXISTS
(
[DimTime.CalendarYearMonthNum].[CalendarMonthNum].members,
[DimTime.CalendarYearMonth].[CalendarYearMonth].currentmember,
"SomeMeasureGroup"
).item(0).membervalue