我的SSAS多维数据集具有以下事实和维度,列如下所示
DateKey,UserKey,ActivityKey,ActivityCount
DateKey,Date,Week,Year
UserKey,UserName,Gender
ActivityKey,ActivityName
我已创建了用户和日期的不同计数度量,如下所示
COUNT(NONEMPTY([DimUser]。[UserKey]。[UserKey] .Members,[Measures]。[ActivityCount])
COUNT(NONEMPTY([DimDate]。[DateKey]。[DateKey] .Members,[Measures]。[ActivityCount])
当我按ActivityName切片/转轴时,这些措施都按预期正常工作。
现在我想计算每位用户的平均天数,因此我按照以下方式创建了指标
AVG([DimUser]。[UserKey]。[UserKey] .Members,[Measures]。[Distinct Dates])
但这给了我错误的结果。我也试过了
DIVIDE([Measures]。[Distinct Days],[Measures]。[Distinct Users])
我仍然得到错误的结果......我做错了什么?
答案 0 :(得分:0)
也许只是添加EXISTING
会有帮助吗?
AVG(
EXISTING [DimUser].[UserKey].[UserKey].Members,
[Measures].[Distinct Dates]
)
虽然尝试在AdvWks中重新创建类似的内容,但我似乎在没有EXISTING
的情况下得到了有效的回报:
WITH
MEMBER [Measures].[Avg Count Per Reseller] AS
Avg
( [Reseller].[Reseller].[Reseller].MEMBERS
,[Measures].[Reseller Order Count]
), format_string = "0.0000"
SELECT
{[Measures].[Reseller Order Count],[Measures].[Avg Count Per Reseller]} ON 0
,{[Promotion].[Promotion].[All Promotions].Children} ON 1
FROM [Adventure Works]
WHERE [Date].[Calendar Year].&[2005];