SQL Server Analysis Services 中的一对多关系
我有这些表:
DimDate(PK:DateKey,其他属性)
FactActivationCodes(PK:ActivationCode,IssuedDateKey(FK 到 DimDate)
FactExpirations(PK:ActivationCode + ExpirationType,FK:ActivationCode 到 FactActivationCodes)
我设置了措施计算
Issued Count(FactActivationCodes 中的行数)
Expired Count(FactExpirations 中不同 ActivationCodes 的计数)
这个想法是,FactActivationCodes 有一个激活码,并带有发布日期。激活码可能会年复一年地过期(然后续订),因此它会有一行过期信息。在 FactExpirations(每年一次)中,
我在表中放入了一些测试行;我在 FactActivationCodes 中放入了 3 行(每行都有不同的 IssuedDate),而在 FactExpirations 中只放入了 2 行。当我浏览多维数据集时,我正在查看列上的发行计数和行上的发行日期(维度),它看起来像这样:
Issued Date
January 2008 1
February 2008 1
March 2008 1
但是,当我添加过期计数时,我希望看到 '由于两个事实表之间存在一对多关系,“过期列”仅与与“激活代码”匹配的列进行计数:
Issued Date Expired Date
January 2008 1 1
February 2008 1 1
March 2008 1 0
但是,我像这样对所有内容进行交叉联接,其中包含过期的总数:
Issued Date Expired Date
January 2008 1 2
February 2008 1 2
March 2008 1 2
April 2008 2
May 2008 2
June 2008 2
并且从此,对于我的日期维度中的每个日期条目...我想我没有正确处理关系...我怎样才能获得预期的结果?
I have these tables:
DimDate (PK: DateKey, other attributes)
FactActivationCodes (PK: ActivationCode, IssuedDateKey (FK to DimDate)
FactExpirations (PK: ActivationCode + ExpirationType, FK: ActivationCode to FactActivationCodes)
I set up measures that count the number of rows in
Issued Count (count of rows in FactActivationCodes)
Expired Count (count of distinct ActivationCodes in FactExpirations)
The idea is that the FactActivationCodes has one activation code, with a date when it was issued. The activation code can get expired year after year (and then renewed) so it would have a row for expiration in FactExpirations (one each year)
I put some test rows in the tables; I put 3 rows in FactActivationCodes (different IssuedDate for each) , and only 2 in FactExpirations. When I browse the cube, and I am looking at the count of Issued on columns, and the Issued Date (dimension) on rows, it looks like this:
Issued Date
January 2008 1
February 2008 1
March 2008 1
But then, when I add the Expired Count, I was hoping to see the 'expired column' count with only the ones that match the 'Activation Code' like so, because of the one to many relationship between the two fact tables:
Issued Date Expired Date
January 2008 1 1
February 2008 1 1
March 2008 1 0
But instead, I a cross join of everything like so, with the totals of expired:
Issued Date Expired Date
January 2008 1 2
February 2008 1 2
March 2008 1 2
April 2008 2
May 2008 2
June 2008 2
And onwards, for every date entry in my Date Dimensions... I guess I'm not doing the relationship correctly... how can I get the expected result?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用引用关系的答案: http://technet.microsoft.com/en-我们/library/ms166704.aspx
The answer to use referenced relationship: http://technet.microsoft.com/en-us/library/ms166704.aspx