真的可以在这个 mdx 查询上使用某人的手。我试图在每个用户和每天的基础上生成过去 365 天的滚动中位数。我需要中位数是每个用户响应天数的中位数。这似乎是一个简单的计算,但我看不出如何让它与混合中的交叉连接一起工作。任何帮助将非常感激!如果你甚至有一个关于攻击这个方向的建议,那就太好了。
SET [2Years] AS
'{[FirstOrderDate].[Full Date].&[2010-01-15T00:00:00]:[FirstOrderDate].[Full Date].[2012-08-20T00:00:00]}'
MEMBER [Measures].[2YearMedianLag]
AS
median({[FirstOrderDate].[Full Date].currentmember.lag(365):[FirstOrderDate].[FullDate].currentmember} , [Measures].[Response Days])
SELECT {[Measures].[Response Days], [Measures].[MedianLag]} ON 0,
NonEmpty(crossjoin( [days],
[User].[User ID].children),[Measures].[Response Days]) ON 1
FROM [UserRevenue]
预先感谢您的协助。
编辑:
SampleData (UserName varchar(100) null, FirstOrderDate Datetime null, ResponseDays int null)
('Jim', '2001-01-03', 10)
('Fred', '2001-01-03', 80)
('Frank', '2001-01-04', 30)
('Sally', '2001-01-05', 18)
('Joan', '2001-01-06', 26)
('Bill', '2001-01-06', 15)
('Ted', '2001-01-08', 29)
('Sam', '2001-01-10', 9)
('Jane', '2001-01-17', 200)
SampleOutput (FirstOrderDate datetime null, MedianResponseDays int null)
('2001-01-03', 45)
('2001-01-04', 30)
('2001-01-05', 24)
('2001-01-06', 22)
('2001-01-07', 22)
('2001-01-08', 26)
('2001-01-09', 26)
('2001-01-10', 22)
('2001-01-11', 22)
('2001-01-12', 22)
('2001-01-13', 22)
('2001-01-14', 22)
('2001-01-15', 22)
('2001-01-16', 22)
('2001-01-17', 26)