合并2个MDX查询 [英] Merge 2 MDX queries

查看:154
本文介绍了合并2个MDX查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在一个表中显示这两个查询的结果.

I would like to show outcome of these 2 queries in one table.

SELECT
{[Measures].[Udzial Wieznia w Aktywnosci Count]} ON COLUMNS,
{[Aktywnosc].[Id Wiezienia].Members} ON ROWS
FROM [Wiezienia HD2]
WHERE [Udzial Wieznia w Aktywnosci].[Id Ucieczki].[2] : [Udzial Wieznia w Aktywnosci].[Id Ucieczki].[101]

SELECT
{[Measures].[Udzial Wieznia w Aktywnosci Count]} ON COLUMNS,
{[Aktywnosc].[Id Wiezienia].Members} ON ROWS
FROM [Wiezienia HD2]

第一个显示每个监狱中有多少人逃离监狱,第二个显示每个监狱中有多少人.

First one shows how many escapes from jail there were in each jail, and second one show how many people are in each jail.

推荐答案

这是亚伦·韦斯特(Aaron West)移植到AdvWrks的建议:

This is the suggestion of Aaron West ported over to AdvWrks:

SELECT 
  {
    [Measures].[Internet Sales Amount]
   ,Aggregate
    (
        [Date].[Calendar].[Calendar Year].&[2006]
      : [![enter image description here][1]][1]
        [Date].[Calendar].[Calendar Year].&[2007]
     ,[Measures].[Internet Sales Amount]
    )
  } ON 0
 ,[Product].[Category].[Category] ON 1
FROM [Adventure Works];

如格雷格·加洛韦(Greg Galloway)指出的那样,错误:

As pointed out by Greg Galloway it errors:

查询(2,3)该函数期望2的元组设置表达式 争论.使用了字符串或数字表达式.

Query (2, 3) The function expects a tuple set expression for the 2 argument. A string or numeric expression was used.

如果将计算移至WITH语句:

WITH 
  MEMBER [Measures].[SalesIn2006/2007] AS 
    Aggregate
    (
        [Date].[Calendar].[Calendar Year].&[2006]
      : 
        [Date].[Calendar].[Calendar Year].&[2007]
     ,[Measures].[Internet Sales Amount]
    ) 
SELECT 
  {
    [Measures].[Internet Sales Amount]
   ,[Measures].[SalesIn2006/2007]
  } ON 0
 ,[Product].[Category].[Category] ON 1
FROM [Adventure Works];

我们现在得到一个结果:

We now get a result:

因此,对于您的多维数据集,它可能看起来像这样:

So against your cube it'll probably look a little like this:

WITH 
  MEMBER [Measures].[Count freeAtLast] AS 
    Aggregate
    (
        [Udzial Wieznia w Aktywnosci].[Id Ucieczki].[2]
      : 
        [Udzial Wieznia w Aktywnosci].[Id Ucieczki].[101]
     ,[Measures].[Udzial Wieznia w Aktywnosci Count]
    ) 
SELECT 
  {
    [Measures].[Udzial Wieznia w Aktywnosci Count]
   ,[Measures].[Count freeAtLast]
  } ON 0
 ,[Aktywnosc].[Id Wiezienia].MEMBERS ON 1
FROM [Wiezienia HD2];

这篇关于合并2个MDX查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆