Cube 计算成员问题

发布于 2024-08-02 07:18:15 字数 445 浏览 7 评论 0原文

我对 SSAS 相当陌生,完全不知道如何解决这个问题。我有一个称为阈值的维度。在阈值维度中,有以下成员:

[阈值年份]、[阈值 1 金额]、[阈值 2 金额]、[阈值 3 金额]

我还有一个名为 [合格佣金]、[第 1 级金额]、[第 2 级金额] 的衡量标准, [Tier3 Amount]

除此之外,还有一个时间维度,称为 [Statement Dates]

所以基本上这就是我想要做的。我想创建一个计算成员,当最终用户从[报表日期]中选择一个时间范围时,我想总结[合格佣金]并将其与相应年份的阈值金额进行检查。如果它大于 [Threshold1 Amount],我希望它返回 [Tier1 Amount] 度量,并使用与阈值 2 和 3 相同的逻辑。

有人能给我一个关于我需要做什么的路线图吗?如果我需要重组底层数据库中的数据才能完成这项工作,那么了解这一点将非常有帮助。先谢谢您的帮助。

I'm rather new to SSAS and am completely stumped on how to solve this problem. I have a dimension called Thresholds. Within the Thresholds dimension there are the following Members:

[Threshold Year], [Threshold1 Amount], [Threshold2 Amount], [Threshold3 Amount]

I also have a measures called [Qualifying Commission], [Tier1 Amount], [Tier2 Amount], [Tier3 Amount]

On top of that there is also a time dimension called [Statement Dates]

So basically here is what I am trying to do. I want to create a calculated member that when an end user selects a time frame from [Statement Dates] I want to sum up [Qualifying Commission] and check it against the threshold amounts for the corresponding year. If it is greater than [Threshold1 Amount], I want it to return the [Tier1 Amount] measure with the same logic applying to thresholds 2 and 3.

Can somebody give me a road map on what I need to do? If I need to restructure the data in the underlying database to make this work then that would be really helpful to know. Thanks in advance for the help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

初与友歌 2024-08-09 07:18:15

好吧,我们假设[Qualifying Commission] 是一项附加措施,这意味着该金额由 SSAS 为我们处理。

本质上,我们只需要在[Statement Dates]下找到我们所处的年份即可获得阈值。

那么,让我们把它分成几个部分。我们要做的第一件事是找到正确的[阈值年份]

create set [Current Threshold] as
    iif([Statement Dates].[YQM].CurrentMember IS [All]
        ,[Threshold Year].[All]
        ,StrToSet("[Threshold Year].[" + 
            Ancestor([Statement Dates].[YQM].CurrentMember
            , [Statement Dates].[YQM].[Year]).Name +  
        "]"))

接下来,我们将应用此阈值来获得正确的数字:

create member currentcube.[Measures].[Threshold Amount] as
    case
        when [Qualifying Commission] > 
                 [Current Threshold].Item(0).Properties("Threshold1 Amount") then
            [Measures].[Tier1 Amount]
        when [Qualifying Commission] > 
                 [Current Threshold].Item(0).Properties("Threshold2 Amount") then
            [Measures].[Tier2 Amount]
        when [Qualifying Commission] > 
                 [Current Threshold].Item(0).Properties("Threshold3 Amount") then
            [Measures].[Tier3 Amount]
        else 0
    end

瞧,您正在用煤气做饭。

Well, let's assume that [Qualifying Commission] is an additive measure, meaning the sum is taken care of for us by SSAS.

Essentially, we just need to find whatever year we're in under [Statement Dates] to get our thresholds.

So, let's break it into some chunks. The first thing we do is to find our right [Threshold Year]:

create set [Current Threshold] as
    iif([Statement Dates].[YQM].CurrentMember IS [All]
        ,[Threshold Year].[All]
        ,StrToSet("[Threshold Year].[" + 
            Ancestor([Statement Dates].[YQM].CurrentMember
            , [Statement Dates].[YQM].[Year]).Name +  
        "]"))

Next, we'll apply this threshold to get the right number:

create member currentcube.[Measures].[Threshold Amount] as
    case
        when [Qualifying Commission] > 
                 [Current Threshold].Item(0).Properties("Threshold1 Amount") then
            [Measures].[Tier1 Amount]
        when [Qualifying Commission] > 
                 [Current Threshold].Item(0).Properties("Threshold2 Amount") then
            [Measures].[Tier2 Amount]
        when [Qualifying Commission] > 
                 [Current Threshold].Item(0).Properties("Threshold3 Amount") then
            [Measures].[Tier3 Amount]
        else 0
    end

And voila, you're cooking with gas.

∝单色的世界 2024-08-09 07:18:15

您还应该考虑使用范围运算符。当您需要实现条件求和时,它可以帮助提高性能。

范围运算符来自 MSDN

You should also look into using the scope operator. It can help performance when you need to implement conditional sums.

Scope operator From MSDN

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文