我正在尝试将我的第一个查询放在一起pentaho
CDE信息中心图表。
开始查询
WITH
SET [~COLUMNS] AS
{[DimProgram.Name].[Name].MEMBERS}
SET [~ROWS] AS
{[DimTime.CalendarYearMonth].[CalendarYearMonth].MEMBERS}
SELECT
NON EMPTY
CrossJoin
(
[~COLUMNS]
,{[Measures].[SubmissionCount]}
) ON COLUMNS
,NON EMPTY
[~ROWS] ON ROWS
FROM [PSE_FactSubmission];
此查询返回我想要的数据,但需要稍微调整一下以备实际使用。我想按日期降序排序,并限制为过去12个月。
我已经阅读了几个关于MDX排序的网页,但是还没有能够将一个将要运行的查询放在一起。当查询没有运行"错误"提示。
订购尝试
WITH
SET [~COLUMNS] AS
{[DimProgram.Name].[Name].MEMBERS}
SELECT
NON EMPTY
CrossJoin
(
[~COLUMNS]
,{[Measures].[SubmissionCount]}
) ON COLUMNS
,NON EMPTY
Order
(
[DimTime.CalendarYearMonth].[CalendarYearMonth].MEMBERS
,[DimTime.CalendarYearMonth].CurrentMember.Member_Key
,DESC
) ON ROWS
FROM [PSE_FactSubmission];
有关排序或如何限制过去X个月的任何提示都将非常感激。
答案 0 :(得分:0)
通常在多维数据集设计中自然排序日期/时间维度,因此无需使用Order
。我不需要使用我使用的立方体。
如果它在多维数据集中处于奇怪的顺序,那么您需要使用B
或BASC
打破(BDESC
)此等级顺序:
WITH
SET [~COLUMNS] AS
{[DimProgram.Name].[Name].MEMBERS}
MEMBER [Measures].[orderMeas] AS
[DimTime.CalendarYearMonth].CurrentMember.Member_Key
SET [~ROWS] AS
Order
(
[DimTime.CalendarYearMonth].[CalendarYearMonth].MEMBERS
,[Measures].[orderMeas]
,BASC
)
SELECT
NON EMPTY
CrossJoin
(
[~COLUMNS]
,{[Measures].[SubmissionCount]}
) ON COLUMNS
,NON EMPTY
[~ROWS] ON ROWS
FROM [PSE_FactSubmission];
要获得最近的12个月,您可以使用Tail
功能 - 最好在非空月份使用它:
WITH
SET [~COLUMNS] AS
{[DimProgram.Name].[Name].MEMBERS}
MEMBER [Measures].[orderMeas] AS
[DimTime.CalendarYearMonth].CurrentMember.Member_Key
SET [~ROWS] AS
Order
(
NonEmpty
(
[DimTime.CalendarYearMonth].[CalendarYearMonth].MEMBERS
,[Measures].[SubmissionCount]
)
,[Measures].[orderMeas]
,BASC
)
SELECT
NON EMPTY
CrossJoin
(
[~COLUMNS]
,{[Measures].[SubmissionCount]}
) ON COLUMNS
,NON EMPTY
Tail
(
[~ROWS]
,12
) ON ROWS
FROM [PSE_FactSubmission];
嗨,安德鲁 - 反对AdvWrks
我有以下运行没有任何错误。我需要将Member_Key
更改为MemberValue
:
WITH
SET [~COLUMNS] AS
[Product].[Product Categories].[Product]
MEMBER [Measures].[orderMeas] AS
[Date].[Calendar].CurrentMember.MemberValue
SET [~ROWS] AS
Order
(
NonEmpty
(
[Date].[Calendar].[Month].MEMBERS
,[Measures].[Internet Sales Amount]
)
,[Measures].[orderMeas]
,ASC
)
SELECT
NON EMPTY
CrossJoin
(
[~COLUMNS]
,{[Measures].[Internet Sales Amount]}
) ON COLUMNS
,NON EMPTY
Tail
(
[~ROWS]
,12
) ON ROWS
FROM [Adventure Works];