我想在一个表格中显示这两个查询的结果。
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]
第一个显示每个监狱中有多少人从监狱逃脱,第二个显示每个监狱中有多少人。
答案 0 :(得分:0)
WITH MEMBER [Measures].x 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.x
} ON COLUMNS
, [Aktywnosc].[Id Wiezienia].Members ON ROWS
FROM [Wiezienia HD2]
如果AGGREGATE不起作用,请尝试使用SUM。顺便说一下,请注意OrderBy设置为该属性上的KeyColumn(应为数字数据类型),为2到101,否则您的范围将无法正常工作。
编辑:也许我不正确的第一个答案是将聚合内联放入内联,因为我正在考虑这样一个事实,即如果你有一个单元的层次结构成员,那么元组集表达式就像SUM一样。例如,如果您为范围2到101创建了维度属性,则可以使用如下表达式:
( [Udzial Wieznia w Aktywnosci].[new attribute name].[2_to_101]
, [Measures].[Udzial Wieznia w Aktywnosci Count] )
但是你需要确保元组的维度在轴上的所有成员中都是相同的,例如:
SELECT { ( [Udzial Wieznia w Aktywnosci].[new attribute name].[2_to_101]
, [Measures].[Udzial Wieznia w Aktywnosci Count] )
( [Udzial Wieznia w Aktywnosci].[new attribute name].[All]
, [Measures].[Udzial Wieznia w Aktywnosci Count] )
} ON COLUMNS
, [Aktywnosc].[Id Wiezienia].Members ON ROWS
FROM [Wiezienia HD2]
答案 1 :(得分:0)
这是Aaron West建议移到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指出的那样,错误:
Query(2,3)函数需要2的元组集表达式 论点。使用了字符串或数字表达式。
如果我们将计算移到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];
我们现在得到一个结果:
所以对你的立方体来说,它可能看起来有点像这样:
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];