在MDX查询中

请考虑以下MDX查询:

SELECT {[Measures].[Internet Sales Amount]} ON COLUMNS,[Date].[Calendar Year].MEMberS ON ROWS  
FROM [Adventure Works]  

如何使用以下三个条件在上述查询中添加WHERE子句:

1)其中[Customer].[Customer Geography].[Country].&[United States] AND [Product].[Category].&[Bike]

2)其中[Customer].[Customer Geography].[Country].&[United States] OR [Product].[Category].&[Bike]

3)其中([Customer].[Customer Geography].[Country].&[United States] OR [Product].[Category].&[Bike]) AND [Date].[Year].&[2008]

谢谢

hushilan325 回答:在MDX查询中

  

1)哪里[客户]。[客户地理]。[国家/地区]。&[美国]   AND [产品]。[类别]。&[自行车]

为此,您的where子句将

Where ([Customer].[Customer Geography].[Country].&[United States],[Product].[Category].&[Bike])

上面的代码定义了一个元组,该元组包含来自United States Bikes Sales的数据

  

2)哪里[客户]。[客户地理]。[国家/地区]。&[美国]或   [产品]。[类别]。&[自行车]

为此,您的Where子句将是

Where 
{([Customer].[Customer Geography].[Country].&[United States],[Product].[Category].defaultmember),([Customer].[Customer Geography].[Country].[Country],[Product].[Category].&[Bike])}

在这种情况下,您需要国家(地区)为美国或产品为自行车时的数据。所以我定义了两个元组,第一个表示国家是美国,产品类别可以是任何产品类别。在下一个元组中,我说国家可以是任何国家,但是产品是Bike。在MDX中,集合中的每个元组在层次结构和层次结构位置上均应相等。在上述情况下,我无法说出

{
([Customer].[Customer Geography].[Country].&[United States]),([Product].[Category].&[Bike])
}

在MDX中无法使用此Set,因此在我提到的第一个元组中 “ [Product]。[Category] ​​.defaultmember”表示未定义任何特定值,类似地,在下一个元组中,我使用了[[Customer]。[Customer Geography]。[Country]。[Country]“,因为这是用户层次结构I无法使用默认成员,所以我使用了此表达式。

  

3)哪里([客户]。[客户地理]。[国家/地区]。[美国]   或[产品]。[类别]。[自行车])和[日期]。[年份]。[2008]

为此,您需要修改where子句和on行。因此,对于这一部分,您的查询将为

SELECT {[Measures].[Internet Sales Amount]} ON COLUMNS,[Date].[Calendar Year].&[2011] ON ROWS -- in my sample the strong name of 2011 is &[2011] yours may be diffrent 
    FROM [Adventure Works] 
    Where 
    {([Customer].[Customer Geography].[Country].&[United States],[Product].[Category].&[Bike])}
本文链接:https://www.f2er.com/3166374.html

大家都在问