我正在尝试使用基础 SQL Server 2008 Analysis Services 数据库为 Team Foundation Server 2010 创建一些报告。多维数据集“团队系统”是随 TFS 2010 报告一起提供的。
我的问题是。我尝试使用 FactWorkItemHistory 的 StateChangeCount 度量。在某些时间段内,工作项状态没有变化,但有其他变化。因此,我们有一些事实行具有 NULL StateChangeCount,如下所述。
即使基础事实行包含 NULL 值,State Change Count 度量有时也会产生 0 值。此度量定义为 [FactWorkItemHistory].[StateChangeCount] 上的 SUM。NULLS 的 SUM 返回 0 是设计使然还是我遗漏了什么?有问题的时期是 2013-03-01(3 月)和 2013-05-02(5 月)。
SELECT
[DateSK],
COUNT(*) AS COUNT,
SUM([StateChangeCount]) AS SUM
FROM
[Tfs_Warehouse].[dbo].[FactWorkItemHistory]
WHERE
[WorkItemSK] IN (SELECT [WorkItemSK] FROM [Tfs_Warehouse].[dbo].[DimWorkItem] WHERE [System_WorkItemType] = 'Bug')
GROUP BY
[DateSK]
输出是:
DateSK COUNT SUM
---------------------------------------
2011-05-05 00:00:00.000 13 7
2012-03-01 00:00:00.000 2 NULL
2012-09-28 00:00:00.000 60 2
2013-05-02 00:00:00.000 16 NULL
2013-05-06 00:00:00.000 9 9
查询:
SELECT
[DateSK],
[StateChangeCount]
FROM
[Tfs_Warehouse].[dbo].[FactWorkItemHistory]
WHERE
[WorkItemSK] IN (SELECT [WorkItemSK] FROM [Tfs_Warehouse].[dbo].[DimWorkItem] WHERE [System_WorkItemType] = 'Bug')
ORDER BY
[DateSK]
给出:
DateSK StateChangeCount
---------------------------------------
2011-05-05 00:00:00.000 1
2011-05-05 00:00:00.000 NULL
2011-05-05 00:00:00.000 NULL
2011-05-05 00:00:00.000 1
2011-05-05 00:00:00.000 NULL
2011-05-05 00:00:00.000 1
2011-05-05 00:00:00.000 NULL
2011-05-05 00:00:00.000 1
2011-05-05 00:00:00.000 NULL
2011-05-05 00:00:00.000 1
2011-05-05 00:00:00.000 NULL
2011-05-05 00:00:00.000 1
2011-05-05 00:00:00.000 1
2012-03-01 00:00:00.000 NULL
2012-03-01 00:00:00.000 NULL
2012-09-28 00:00:00.000 1
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 1
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2012-09-28 00:00:00.000 NULL
2013-05-02 00:00:00.000 NULL
2013-05-02 00:00:00.000 NULL
2013-05-02 00:00:00.000 NULL
2013-05-02 00:00:00.000 NULL
2013-05-02 00:00:00.000 NULL
2013-05-02 00:00:00.000 NULL
2013-05-02 00:00:00.000 NULL
2013-05-02 00:00:00.000 NULL
2013-05-02 00:00:00.000 NULL
2013-05-02 00:00:00.000 NULL
2013-05-02 00:00:00.000 NULL
2013-05-02 00:00:00.000 NULL
2013-05-02 00:00:00.000 NULL
2013-05-02 00:00:00.000 NULL
2013-05-02 00:00:00.000 NULL
2013-05-02 00:00:00.000 NULL
2013-05-06 00:00:00.000 1
2013-05-06 00:00:00.000 1
2013-05-06 00:00:00.000 1
2013-05-06 00:00:00.000 1
2013-05-06 00:00:00.000 1
2013-05-06 00:00:00.000 1
2013-05-06 00:00:00.000 1
2013-05-06 00:00:00.000 1
2013-05-06 00:00:00.000 1
最后是 MDX 查询:
SELECT
NON EMPTY { [Measures].[State Change Count] } ON COLUMNS,
NON EMPTY { ([Date].[Date].[Date].ALLMEMBERS * [Work Item].[System_State]. [System_State].ALLMEMBERS ) }
ON ROWS FROM (
SELECT (
{ [Work Item].[System_WorkItemType].&[Bug] }
)
ON COLUMNS FROM [Team System])
WHERE ( [Work Item].[System_WorkItemType].&[Bug] )
结果是:
StateChangeCount
---------------------------------------------
2011-05-05 Assigned 4
2011-05-05 For verification 2
2011-05-05 In progress 1
2012-03-01 Assigned 0
2012-09-28 Assigned 2
2013-05-02 Assigned 0
2013-05-06 Assigned 9
尽管
SELECT
NON EMPTY { [Measures].[State Change Count] } ON COLUMNS,
NON EMPTY { ([Date].[Date].[Date].ALLMEMBERS * [Work Item].[System_State]. [System_State].ALLMEMBERS ) }
ON ROWS FROM (
SELECT (
{ [Work Item].[System_WorkItemType].&[Bug] }
)
ON COLUMNS FROM [Team System])
WHERE ( [Work Item].[System_WorkItemType].&[Bug] )
是:
State Change Count
------------------------------------
May 2011 7
June 2011 (null)
July 2011 (null)
August 2011 (null)
September 2011 (null)
October 2011 (null)
November 2011 (null)
December 2011 (null)
January 2012 (null)
February 2012 (null)
March 2012 0
April 2012 (null)
May 2012 (null)
June 2012 (null)
July 2012 (null)
August 2012 (null)
September 2012 2
October 2012 (null)
November 2012 (null)
December 2012 (null)
January 2013 (null)
February 2013 (null)
March 2013 (null)
April 2013 (null)
May 2013 9
June 2013 (null)
July 2013 (null)
August 2013 (null)
Unknown (null)
我可以看到,对于有问题的时期,有一些事实行,但包含其他工作项数据更改。我希望这些项目不应该污染结果,特别是对于 SUM。对于 COUNT,同意,看到零值很好,但对于 SUM 则不行。
任何帮助将不胜感激。
谢谢你