MDX添加计算的平均成员

时间:2013-04-16 11:33:35

标签: mdx average

我有一个工作查询,我想稍微改变一下。

工作查询为我提供了用户参与的每个广告系列的计算度量值。

由于在此查询示例中,对于此用户参与的2个广告系列,有2个计算值0和7,我应该能够将查询转换为显示具有两个值的平均值的单个用户行,例如3.5。

那就是我被困住的地方。有谁知道如何在结果中添加 - 替换[日间差异曝光下载]到[平均日差...]计算?

非常感谢你的帮助。

以下是原始工作查询:

with
member [measures].FirstEventDate as CDate(Head(NonEmpty([DIM DATE].[Date].[Date], ([Measures].[Count], [DIM USER].[Email].CurrentMember, [DIM CAMPAIGN].[Campaign].CurrentMember))).item(0).member_caption)
member [measures].[Day Diff Exposure to Download] as ([DIM EVENT].[Event].[Event Name].&[download], [measures].FirstEventDate) - ([DIM EVENT].[Event].[Event Name].&[exposure], [measures].FirstEventDate)
select
[measures].[Day Diff Exposure to Download] on columns,
NonEmpty (
    {([DIM USER].[Email].[User Email].&[100000@mail.com],
    [DIM CAMPAIGN].[CampaignTypeName].[Campaign Name])},
    [DIM EVENT].[Event].[Event Name].&[download]
) on rows
from [MyCube]

以下是我目前未成功升级查询的尝试:

with
member [measures].FirstEventDate as CDate(Head(NonEmpty([DIM DATE].[Date].[Date], ([Measures].[Count], [DIM USER].[Email].CurrentMember, [DIM CAMPAIGN].[Campaign].CurrentMember))).item(0).member_caption)
member [measures].[Day Diff Exposure to Download] as ([DIM EVENT].[Event].[Event].&[download], [measures].FirstEventDate) - ([DIM EVENT].[Event].[Event].&[exposure], [measures].FirstEventDate)
member [measures].[Avg Day Diff] as
Avg(
    NonEmpty(
        {[DIM CAMPAIGN].[Campaign].[Campaign]},
        (
            [DIM USER].[Email].CurrentMember,
            [DIM EVENT].[Event].[Event].&[download]
        )
    ),
    [measures].[Day Diff Exposure to Download]
)
select
[measures].[measures].[Avg Day Diff] on columns,
NonEmpty (
    {[DIM USER].[Email].[Email].&[100000@mail.com]},
    [DIM EVENT].[Event].[Event].&[download]
) on rows
from [MyCube]

不幸的是,暂时尝试的查询不返回值3.5,而是返回-13738.3333333。

1 个答案:

答案 0 :(得分:1)

您可能还需要在nonEmpty集中指定度量;类似的东西:

NonEmpty( [measures].FirstEventDate * { ... } )