MDX将标准化一组度量

MDX将标准化一组度量,mdx,Mdx,我正在尝试为SSRS报告创建数据集,如下所述: 挑战在于,我有多个度量值,我希望在“度量值”列中包含这些度量值的数据,并且我希望在“行值”列中包含度量值的名称。因此,以下查询仅返回度量值“Sales Amount”的数据: 我要做的是运行以下类型的查询,但在上面的查询结构中返回数据,这将允许我将其插入SSRS报告矩阵: WITH MEMBER measures.SalesAmount AS [Measures].[Sales Amount] MEMBER meas

我正在尝试为SSRS报告创建数据集,如下所述:

挑战在于,我有多个度量值,我希望在“度量值”列中包含这些度量值的数据,并且我希望在“行值”列中包含度量值的名称。因此,以下查询仅返回度量值“Sales Amount”的数据:

我要做的是运行以下类型的查询,但在上面的查询结构中返回数据,这将允许我将其插入SSRS报告矩阵:

WITH 
       MEMBER measures.SalesAmount AS [Measures].[Sales Amount]
       MEMBER measures.CustomerCount AS [Measures].[Customer Count]
       MEMBER measures.InternetFreightCost AS [Measures].[Internet Freight Cost]
SELECT [Date].[Calendar Year].[Calendar Year].Members ON COLUMNS, 
    {measures.SalesAmount,measures.CustomerCount,measures.InternetFreightCost} ON ROWS
FROM [Adventure Works]
MDX忍者中有人知道MDX是否可以做到这一点吗?

会员[地理].[城市].[销售额]为1
with member [Geography].[City].[Sales Amount] as 1
     member [Geography].[City].[Customer Count] as 1
     member [Geography].[City].[Freight Cost] as 1
     member [Measures].[RowValue] as [Geography].[City].CurrentMember.Name
     member [Measures].[ColumnValue] as [Date].[Calendar Year].CurrentMember.Name
     member [Measures].[Measure] as 
            CASE
                WHEN [Geography].[City].CurrentMember IS [Geography].[City].[Sales Amount]
                     THEN ([Measures].[Internet Sales Amount], [Geography].[City].[All Geographies])
                WHEN [Geography].[City].CurrentMember IS [Geography].[City].[Customer Count]
                     THEN ([Measures].[Customer Count], [Geography].[City].[All Geographies])
                WHEN [Geography].[City].CurrentMember IS [Geography].[City].[Freight Cost]
                     THEN ([Measures].[Internet Freight Cost], [Geography].[City].[All Geographies])
            END

select {[Measures].[RowValue], [Measures].[ColumnValue], [Measures].[Measure]}
       on columns,
       { [Geography].[City].[Sales Amount], [Geography].[City].[Customer Count], [Geography].[City].[Freight Cost]}
         * 
       [Date].[Calendar Year].[Calendar Year].Members
       having [Measures].[Measure] <> null
       on rows
from [Adventure Works]
成员[地理][城市][客户计数]为1 成员[地理][城市][运费]为1 成员[Measures].[RowValue]为[Geography].[City].CurrentMember.Name 成员[度量].[ColumnValue]为[日期].[日历年].CurrentMember.Name 成员[措施][措施]作为 案例 当[Geography].[City].CurrentMember为[Geography].[City].[Sales Amount]时 然后([测量].[互联网销售额],[地理].[城市].[所有地理]) 当[Geography].[City].CurrentMember为[Geography].[City].[Customer Count]时 然后([测量].[客户数量],[地理].[城市].[所有地理]) 当[Geography].[City].CurrentMember为[Geography].[City].[运费] 然后([测量].[互联网运费],[地理].[城市].[所有地理]) 结束 选择{[Measures].[RowValue],[Measures].[ColumnValue],[Measures].[Measures]} 在专栏上, {[地理].[城市].[销售额],[地理].[城市].[客户数量],[地理].[城市].[运费]} * [日期][日历年][日历年].成员 具有[Measures][Measures]null的 成排 来自[冒险作品]
你应该提供你想要的。我使用
[Geography].[City]
作为实用程序层次结构。这可以是查询中未使用的任何层次结构。我选择了这个,因为它与查询中使用的两个度量值组无关,因此不太可能在任何查询中使用。一些多维数据集设计者在其多维数据集中创建一个或两个与任何度量值组无关的单成员虚拟维度,并且可以像这里一样使用这些维度,以便在其上创建计算成员

ReportingServices查询的困难之一是度量值必须始终在列中,列中不能有其他层次结构。因此,如果我们想在行中包含度量值,我们必须将它们移动到另一个层次结构中。这是通过两个步骤完成的:首先,我们在实用程序层次结构上创建虚拟成员,然后将它们映射到
[Measures].[measure]
定义的
CASE
构造中所需的度量值,其中我们需要使用实用程序维度的默认成员(在大多数情况下是All成员)为了得到不同于我用于虚拟值的1的东西


最后:
non-empty
不能与此构造一起正常工作,因为
[Measures].[RowValue]
[Measures].[ColumnValue]
从不为空。因此,我将其替换为
have
,它可以查看行中的特定列值。

对于您引用的文章中描述的查询结构,您需要什么灵活性?是否有其他查询需要为同一个报表提供数据,这些报表的行中只有一个度量值和任意层次结构,列中有另一个?或者您的所有报告在列中都有一个层次结构(如示例中的年份),在行中有一个或多个度量值?您好,Frank,我在列中只有一个层次结构(始终是日期)。但我确实需要包括多种措施。
with member [Geography].[City].[Sales Amount] as 1
     member [Geography].[City].[Customer Count] as 1
     member [Geography].[City].[Freight Cost] as 1
     member [Measures].[RowValue] as [Geography].[City].CurrentMember.Name
     member [Measures].[ColumnValue] as [Date].[Calendar Year].CurrentMember.Name
     member [Measures].[Measure] as 
            CASE
                WHEN [Geography].[City].CurrentMember IS [Geography].[City].[Sales Amount]
                     THEN ([Measures].[Internet Sales Amount], [Geography].[City].[All Geographies])
                WHEN [Geography].[City].CurrentMember IS [Geography].[City].[Customer Count]
                     THEN ([Measures].[Customer Count], [Geography].[City].[All Geographies])
                WHEN [Geography].[City].CurrentMember IS [Geography].[City].[Freight Cost]
                     THEN ([Measures].[Internet Freight Cost], [Geography].[City].[All Geographies])
            END

select {[Measures].[RowValue], [Measures].[ColumnValue], [Measures].[Measure]}
       on columns,
       { [Geography].[City].[Sales Amount], [Geography].[City].[Customer Count], [Geography].[City].[Freight Cost]}
         * 
       [Date].[Calendar Year].[Calendar Year].Members
       having [Measures].[Measure] <> null
       on rows
from [Adventure Works]