0

我有两个度量:[Measure].[ChildCount] 和 [Measure].[Buyings] 和两个维度:[Buyers] 和 [Sellers]。

[Measure].[ChildCount] 使用 [Buyers] 维度计算每个买家的子组织。[Measure].[Buyings] 使用 [Buyers] 和 [Sellers] 计算从 [Seller] 到 [Buyer] 的购买。

我想要实现的是为 ChildCount < 1 的买家和 ChildCount > 0 的买家选择所有购买。

目前这些查询工作正常:第一个计算每个发件人/买家的购买:

SELECT [Measure].[Buyings] on COLUMNS,
[Sellers].[Code].[Code] *
[Buyers].[Code].[Code] ON ROWS
FROM MyCube

第二个计算有孩子和没有孩子的买家的购买量:

WITH MEMBER [Measure].[BuyingsWithChilds]
as SUM
(
FILTER([Buyers].[Code].[Code],[Measure].[ChildCount]>0),
[Measure].[Buyings]
)
MEMBER [Measure].[BuyingsWithoutChilds] 
as SUM
(
FILTER([Buyers].[Code].[Code],[Measure].[ChildCount]<1),
[Measure].[Buyings]
)
SELECT
{
[Measure].[BuyingsWithChilds],
[Measure].[BuyingsWithoutChilds]
} ON COLUMNS,
[Buyers].[Code].[Code] ON ROWS
FROM MyCube

但是,如果我尝试将这些查询组合成所需的查询:

    WITH MEMBER [Measure].[BuyingsWithChilds]
    as SUM
    (
    FILTER([Buyers].[Code].[Code],[Measure].[ChildCount]>0),
    [Measure].[Buyings]
    )
    MEMBER [Measure].[BuyingsWithoutChilds] 
    as SUM
    (
    FILTER([Buyers].[Code].[Code],[Measure].[ChildCount]<1),
    [Measure].[Buyings]
    )
    SELECT
    {
    [Measure].[BuyingsWithChilds],
    [Measure].[BuyingsWithoutChilds]
    } ON COLUMNS,
    [Sellers].[Code].[Code] ON ROWS
    FROM MyCube

这个查询的执行需要很长时间。是否可以修复或优化此问题?

4

1 回答 1

0

如果将[Measure].[ChildCount]>0和转换[Measure].[ChildCount]<1为“HasChildren”之类的属性,则可以避免使用Filter通常很慢且使用两次的函数。

那么你的WITH条款将被简化为

WITH MEMBER [Measure].[BuyingsWithChilds]
as ([Buyers].[HasChildren].[Yes], [Measure].[Buyings])
MEMBER [Measure].[BuyingsWithoutChilds]
as ([Buyers].[HasChildren].[No], [Measure].[Buyings])

这应该快得多,因为它使用[Measure].[Buyings].

于 2013-11-06T22:22:25.280 回答