ssas - MDX 查询中的 And-Or
问题描述
请考虑以下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]
谢谢
解决方案
1) [客户].[客户地理位置].[国家].&[美国] AND [产品].[类别].&[自行车]
为此,您的 where 子句将是
Where ([Customer].[Customer Geography].[Country].&[United States], [Product].[Category].&[Bike])
上面的代码定义了一个元组,它包含来自 United States Bikes Sales 的数据
2) [客户].[客户地理位置].[国家].&[美国] OR [产品].[类别].&[自行车]
为此,您的 Where 子句将是
Where
{([Customer].[Customer Geography].[Country].&[United States], [Product].[Category].defaultmember),
([Customer].[Customer Geography].[Country].[Country], [Product].[Category].&[Bike])}
在这种情况下,您需要国家是美国或产品是自行车时的数据。所以我定义了两个元组,第一个表示国家是美国,产品类别可以是任何产品类别。在下一个元组中,我说国家可以是任何国家,但产品是自行车。在 MDX 中,集合中的每个 Tuple 在层次结构和层次结构的位置方面应该是相等的。在上述情况下,我无法做出一套说法
{
([Customer].[Customer Geography].[Country].&[United States]),
([Product].[Category].&[Bike])
}
这个集合在 MDX 中是不可能的,因此在第一个元组中我提到了“[Product].[Category].defaultmember”,这意味着没有定义特定的值,类似地在下一个元组中我使用了“[Customer].[Customer Geography] .[Country].[Country]" 因为这是用户层次结构,所以我不能使用默认成员,所以我使用了这个表达式。
3) Where ([Customer].[Customer Geography].[Country].&[United States] OR [Product].[Category].&[Bike]) AND [Date].[Year].&[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].defaultmember),
([Customer].[Customer Geography].[Country].[Country], [Product].[Category].&[Bike])}
推荐阅读
- html - 创建带有圆圈内图标的复选框
- sql-server - SQL Server 上的循环
- java - Java - 如何为类外变量抛出 IllegalArgumentException
- apache - Apache httpd 服务器不接受来自 F5 负载平衡器的 GET HTTP 请求
- android - 收到异常 FAILED_PRECONDITION: The query requires an index
- python - 如何使用 Python Scout Client 将许多文档发送到 Python 中的 Scout 服务器?
- javascript - 在 Laravel 中选择国家后没有出现任何状态
- arrays - Haskell - 重现 numpy 的重塑
- excel - 使用 VBA 将数据点格式化为图表中数据的最后一个点的问题
- javascript - 以当前日期作为初始值显示当前星期