在StrToMember中使用多个值

时间:2014-05-12 05:36:11

标签: sql-server tfs ssas mdx

我正在尝试自定义与TFS捆绑在一起的SSRS报告。 当前报告仅显示“Active”错误的数据。我需要更改它以显示“新”“已批准”错误。

说明:在我们的环境中,我们将新/已批准的错误视为活动错误,我们不使用活动状态。

这些值需要进行硬编码,因此无需为这些值创建参数。

报告中的当前MDX查询如下:

SELECT
{
    [Measures].[Work Item Count]
} ON COLUMNS,
{
    // Filter out people who don't currently have any work items assigned to them.
    NonEmpty
    (
        CrossJoin
        (
            //
            // This block of code gets the top 10 users, based on how many active bugs they have.
            //
            TopCount(
                NonEmpty(
                    [Work Item].[System_AssignedTo].Children,
                    [Measures].[Work Item Count]
                ),
                @TopUserCount,
                [Measures].[Work Item Count]
            ),
            [Work Item].[Microsoft_VSTS_Common_Priority].[All].Children,
            [Work Item].[Microsoft_VSTS_Common_Severity].[All].Children
        ),
        [Measures].[Work Item Count]
    )
} ON ROWS
FROM
(
    SELECT
        CrossJoin(
            StrToMember("[Team Project].[Project Node GUID].&[{" + @ProjectGuid + "}]"),
            StrToMember("[Work Item].[System_WorkItemType].[" + @BugName + "]"),                   
            StrToMember("[Work Item].[System_State].&[" + @ActiveName + "]"),
            StrToSet(@AreaParam),
            StrToSet(@IterationParam),
            StrToSet(@PriorityParam),
            StrToSet(@SeverityParam)
        ) ON COLUMNS
    FROM [Team System]

我被建议改为以下行:

StrToMember("[Work Item].[System_State].[" + @ActiveName + "]"),

到此:

StrToSet("{[Work Item].[System_State].&[New],[Work Item].[System_State].&[Approved]}")

我尝试了这个,并在执行报告时显示和错误:

An error has occurred during report processing. (rsProcessingAborted)
Query execution failed for dataset 'dsCurrentBugCountAllUsers'. (rsErrorExecutingCommand)
Query (23, 4) Parser: The syntax for 'StrToSet' is incorrect.

我也尝试将其更改为:

StrToSet("{[Work Item].[System_State].[New],[Work Item].[System_State].[Approved]}")

和此:

StrToSet("{[Work Item].[System_State].[New]}")
StrToSet("{[Work Item].[System_State].&[New]}")

所有这些都会产生与上述相同的错误。

有人可以告诉我我做错了吗?

注意:我是MDX中的完整n00b。

1 个答案:

答案 0 :(得分:1)

我相信你想要单个引用而不是双倍。例如,这适用于AdventureWorks多维数据集。

    SELECT StrToSet 
('{[Geography].[Geography].[Country].[Germany],[Geography].[Geography].[Country].[Canada]}')
 ON 0
    FROM [Adventure Works]