MDX计算ALL中的平均值

时间:2017-01-31 18:10:50

标签: mdx

ALL列中,如果是2010年和假期,我想要总收入的平均值,而是获得所有收入的总和。也许有人可以帮忙吗?

WITH 
  MEMBER [Measures].[Income] AS 
    [Measures].[Average Income] 
   ,FORMAT_STRING = '#.## €' 
SELECT 
  {[Measures].[Income]} ON COLUMNS
 ,{
    Filter
    (
      [Order Date].[Date].MEMBERS
     ,(
        [Measures].[Income]
       ,[Order Date].[Holiday].&[True]
      )
    )
  } ON ROWS
FROM [xxxxx]
WHERE 
  [Order Date].[Year].&[2010];

enter image description here

1 个答案:

答案 0 :(得分:0)

是否需要测试,但这项额外措施是否有效?

WITH 
  MEMBER [Measures].[AvgIncome] AS 
    Avg
    (
      Filter
      (
        (EXISTING 
          [Order Date].[Date].MEMBERS)
       ,(
          [Measures].[Income]
         ,[Order Date].[Holiday].&[True]
        )
      )
     ,[Measures].[Average Income]
    ) 
  MEMBER [Measures].[Income] AS 
    [Measures].[Average Income] 
   ,FORMAT_STRING = '#.## €' 
SELECT 
  {
    [Measures].[Income]
   ,[Measures].[AvgIncome]
  } ON COLUMNS
 ,{
    Filter
    (
      [Order Date].[Date].MEMBERS
     ,(
        [Measures].[Income]
       ,[Order Date].[Holiday].&[True]
      )
    )
  } ON ROWS
FROM [xxxxx]
WHERE 
  [Order Date].[Year].&[2010];