我有一个“动作”立方体。尺寸是“时间”和“动作ID”,测量值是“动作次数”和“总时间”以及计算的测量值“平均动作时间”。 我试图通过平均时间计算前5个动作,并显示前一天的变化。 我可以在两个单独的查询中执行此操作:
SELECT {[Measures].[Avg Action Time]} ON COLUMNS,
NON EMPTY TopCount( except([Action ID].members, {[Action ID].[All Action IDs]}), 5, [Measures].[Avg Action Time]) ON ROWS
FROM Actions
WHERE [Time].[2005].[1];
和
WITH MEMBER [Measures].[Change] AS
([Time].CurrentMember, [Measures].[Number of Actions]) / (ParallelPeriod ([Day], 1, [Time].CurrentMember), [Measures].[Number of Actions]),
FORMAT_STRING = 'Percent'
SELECT [Measures].[Change] on COLUMNS,
NON EMPTY [Time].[2005].[1].children on ROWS
FROM [Actions];
但我无法弄清楚如何将它们组合成一个MDX查询。 我试过了:
WITH MEMBER [Measures].[Change] AS
([Time].CurrentMember, [Action ID].CurrentMember, [Measures].[Avg Action Time]) / (ParallelPeriod ([Day], 1, [Time].CurrentMember), [Action ID].CurrentMember, [Measures].[Avg Action Time]),
FORMAT_STRING = 'Percent'
SELECT {[Measures].[Avg Action Time], [Measures].[Change]} ON COLUMNS,
NON EMPTY TopCount( except([Action ID].members, {[Action ID].[All Action IDs]}), 5, [Measures].[Avg Action Time]) ON ROWS
FROM Actions
WHERE [Time].[2005].[1];
但改变百分比总是无穷大,所以显然没有计算正确的事情。 什么是正确的查询?
答案 0 :(得分:0)
问题是我的事实表中没有足够的数据。 此查询适用于不同的时间范围。
WITH MEMBER [Measures].[Change] AS
([Time].CurrentMember, [Measures].[Number of Actions]) / (ParallelPeriod ([Day], 1, [Time].CurrentMember), [Measures].[Number of Actions]),
FORMAT_STRING = 'Percent'
SELECT {[Measures].[Avg Action Time], [Measures].[Change]} ON COLUMNS,
NON EMPTY TopCount( except([Action ID].members, {[Action ID].[All Action IDs]}), 5, [Measures].[Avg Action Time]) ON ROWS
FROM Actions
WHERE [Time].[2005].[1].[2];