扩展查询

时间:2016-06-01 10:40:22

标签: mdx

尝试创建要在KPI中使用的计算度量。该度量应计算运行时间大于7天的所有调用(服务台票证)。

使用此查询测试该度量,该查询运行速度快(<3秒)。

WITH MEMBER [Measures].[Count of Calls long runtime] AS         
        Count(
            Filter(
                [Call Details].[Call Number].MEMBERS
                , [Measures].[Closed Call Run Time (days)] > 7
            )
        )
SELECT
    {
        [Count of Calls long runtime]
    } ON 0
FROM
    [Business Intelligence]

但是,在向查询添加其他成员时,突然需要永远完成:

WITH MEMBER [Measures].[Count of Calls long runtime] AS         
Count(
    Filter(
        (
            {
                [Ipc Categorisation].[Categorisation].[Subcategory].&[222]
                ,[Ipc Categorisation].[Categorisation].[Subcategory].&[484]
            }
            , [Call Details].[Call Number].[Call Number].MEMBERS
        )
        , [Measures].[Closed Call Run Time (days)] > 7
    )
)
SELECT
    {
        [Count of Calls long runtime]
    } ON 0
    ,
    {
        [Customer].[Customer].[Customer]
    } ON 1
FROM
    [Business Intelligence]
WHERE
    [Date].[Month Calendar].[Year].&[2016]

应该有大约40个电话出现,超过50个客户。

当我将[调用长时间运行时间]更改为另一个度量(计算或事实表)时,查询运行得很快。

我想了解为什么会这样。我该怎么做才能解决这个问题?

2 个答案:

答案 0 :(得分:0)

最好避免使用

FILTER。它强制计算以逐个单元格模式运行。让我们尝试将计算更改为以块计算模式运行:

WITH MEMBER [Measures].IsGrt7 AS
IIF
 (
     [Measures].[Closed Call Run Time (days)] > 7,
     1,
     NULL
 )

MEMBER [Measures].[Count of Calls long runtime] AS         
SUM
  (        
   {
    [Ipc Categorisation].[Categorisation].[Subcategory].&[222]
    ,[Ipc Categorisation].[Categorisation].[Subcategory].&[484]
   } * [Call Details].[Call Number].[Call Number].MEMBERS
   ,
  [Measures].IsGrt7         
 )

要了解有关此主题的更多信息,请see here

答案 1 :(得分:0)

还值得尝试在击中计算之前将其输入非空命名集:

WITH 
SET [CallNonEmpty] AS
NONEMPTY(
   {
      [Ipc Categorisation].[Categorisation].[Subcategory].&[222]
     ,[Ipc Categorisation].[Categorisation].[Subcategory].&[484]
   } 
  *[Call Details].[Call Number].[Call Number].MEMBERS
 , [Measures].[Closed Call Run Time (days)]
)
MEMBER [Measures].[Count of Calls long runtime] AS
SUM(
   EXISTING [CallNonEmpty], 
   IIF(
     [Measures].[Closed Call Run Time (days)] > 7
    ,1
    ,NULL
   )
)         
SELECT
   [Count of Calls long runtime] ON 0,
   [Customer].[Customer].[Customer] ON 1
FROM [Business Intelligence]
WHERE
   [Date].[Month Calendar].[Year].&[2016];
相关问题