【问题标题】:SSAS and Type 2 SCD DataSSAS 和 2 类 SCD 数据
【发布时间】:2015-01-09 23:52:31
【问题描述】:

我无法通过 SSAS 和 2 类 SCD 数据获得预期结果。下面,我列出了我正在使用的简单表、我得到的 SSAS 输出和我希望的 SSAS 输出。我觉得 SSAS 应该能够像我想要的那样检索数据;我相信我只是很难正确“连接”:)。

我正在使用的表格

DimClient
ID (PK)     AltID (Business Key)     Name        Start Date     End Date
1           1                        Client A    01/01/1995     01/31/1995
2           1                        Client ABC  02/01/1995     NULL

FactSales
ID (PK)     ClientID    Sales     SalesDate
1           1           $100      01/15/1995
2           1           $200      02/15/1995
3           1           $300      03/15/1995

加上一个 DimDate 表,其中包含 01/01/1900 -> 12/31/2050 的每个日期作为 PK 输入,以及它们的各种属性,如月份中的日期、星期几等。等等。

输出(当前与预期)

我正在尝试按月查看客户数据,结果如下:

Month       Client      Sales
January     Client A    $100
February    Client A    $200
March       Client A    $300

当我期待(并希望)看到这个时:

Month       Client      Sales
January     Client A    $100
February    Client ABC  $200
March       Client ABC  $300

为什么我的 SSAS 多维数据集无法识别客户 A 在 2 月和 3 月更改为客户 ABC?

希望能对我的立方体当前是如何连接的提供一些见解:

-FactSales ClientID 链接到 DimClient AltID
-FactSales SalesDate 链接到我的 DimDate PK 字段

我无法以任何方式将 DimClient 链接到 DimDate。

感谢您的意见和帮助解决我的问题!

【问题讨论】:

    标签: ssas scd


    【解决方案1】:

    您需要使用另一个键来链接 FactSales 和 DimClient。

    它是 DimClient 的 ID 和下面描述的新密钥。

    向 FactSales(假设是 ClientSCD)添加另一个键并将其映射到 ETL 阶段,如下所示:

    update f set f.ClientSCD = isnull(c.ID,0)
    /* if you have default NONE member with ID = 0 */
    FactSales f
    left join DimClient c
    on f.ClientID = c.AltID
    and f.SalesDate between c.[Start Date] and isnull(c.[End Date],'12/31/9999')
    

    在您的多维数据集中使用 DimClient.ID 和 FactSales.ClientSCD 作为链接。

    【讨论】:

    • 谢谢亚历克斯。您的解决方案完全符合我的要求!
    猜你喜欢
    • 2021-10-25
    • 1970-01-01
    • 1970-01-01
    • 2015-12-28
    • 1970-01-01
    • 1970-01-01
    • 2021-06-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多