1

我将 MSAS 2008 与 Adventure Works DW 一起使用。这是我想使用 MDX 查询获得的切片的结构:

  • [Product].[Style], [Product].[Product Categories], [Measures].[Discount Amount], [Measures].[Reseller Order Quantity] 行
  • [产品].[颜色] 列

我坚持创建查询以从产品类别层次结构中获取前 2 个成员。问题是我不知道如何为 [Product].[Style] 层次结构创建新的计算 Total 成员。使用下面的查询,我只能为 [Product].[Product Categories] 层次结构创建 Total 成员,但是我所有尝试获取 Style 层次结构的总数都失败了。

WITH 
    SET [Product Color (set)] as 'DRILLDOWNLEVEL(
        {[Product].[Color].[All Products]}
    )'
    SET [Top 2 Categories For Each Style (set)] as 'GENERATE(
        [Product].[Style].[Style],
        TOPCOUNT(
            ([Product].[Style].CURRENTMEMBER, [Product].[Product Categories].[Category]),
            2,
            [Measures].[Discount Amount]
        ) + ([Product].[Style].CURRENTMEMBER, [Product].[Product Categories].[Total])
    )'
    SET [Product Style (set)] as 'DRILLDOWNLEVEL(
        {[Product].[Style].[All Products]}
    )'
    SET [rowSet] AS '[Top 2 Categories For Each Style (set)] *
                     {
                        [Measures].[Discount Amount],
                        [Measures].[Reseller Order Quantity]
                     }'
    SET [columnSet] as '[Product Color (set)]'
    member [Product].[Product Categories].[Total] as 'AGGREGATE(
        TOPCOUNT(
            ([Product].[Style].CURRENTMEMBER, [Product].[Product Categories].[Category]),
            2,
            [Measures].[Discount Amount]
        )
    )'
SELECT 
    [rowSet] ON ROWS, 
    [columnSet] ON COLUMNS 
    FROM [Adventure Works] CELL PROPERTIES VALUE

任何意见,将不胜感激。

4

0 回答 0