English 中文(简体)
SSAS - Sum of Top or Bottom
原标题:SSAS - Sum of Top or Bottom
  • 时间:2012-04-13 13:40:56
  •  标签:
  • sum
  • ssas
  • mdx
SELECT  
  [Measures].[Internet Sales Amount] ON COLUMNS  
 ,Tail  
  (  
    [Date].[Calendar Year].[Calendar Year].MEMBERS  
   ,2  
  ) ON ROWS  
FROM [Adventure Works];  

在MDX查询中,我的产出如下:

因特网销售年限

CY 2003 9,791,060.30美元

2004财政年度:9 770 899.74美元

我理解这一问题是如何运作的,但我想在一个总是给我2年以下时间的河流中制定计算措施。 如何做到这一点? 我是SSAS的新手。 我在设计简单的措施和内容方面做得很好,但在使用MDX时,我大多 st。

PS:我尝试使用TopCount、BottomCount等,但我在此希望通过“年”来订购,这是一个层面。

希望得到任何帮助。

感谢

Parry

最佳回答

下面的询问计算出一项衡量日期最后2年金额的措施:

WITH
MEMBER [Measures].[Sales from the last 2 Years]
    AS Aggregate( Tail( [Date].[Calendar Year].[Calendar Year].Members, 2)
                , [Measures].[Internet Sales Amount]
                )

SELECT { [Measures].[Sales from the last 2 Years]
       } ON COLUMNS
     , { Tail( [Date].[Calendar Year].[Calendar Year].Members, 2)
       } ON ROWS
    FROM [Adventure Works]

其他有趣的询问,将计算每年及以往的总额:

WITH
MEMBER [Measures].[Sales from 2 years]
    AS Aggregate( { [Date].[Calendar Year].CurrentMember.PrevMember
                  : [Date].[Calendar Year].CurrentMember }
                , [Measures].[Internet Sales Amount]
                )

SELECT { [Measures].[Internet Sales Amount]
       , [Measures].[Sales from 2 years]
       } ON COLUMNS
     , NON EMPTY
       { [Date].[Calendar Year].[Calendar Year]
       } ON ROWS
    FROM [Adventure Works]

It does a sum, because the aggregation type of the measure [Measures].[Internet Sales Amount] is Sum, and the Aggregate function aggregates according to the measure s aggregation type.

MDX是一个难以掌握的议题;如果你重新开始,我建议你读到https://rads.stackoverflow.com/amzn/click/com/0471748080” rel=“nofollow noreferer”>。 MDX Solutions, 2nd edition

问题回答

暂无回答




相关问题
In SSAS, can parent-child DATAMEMBER name be customised

In a parent-child dimension in SSAS, the datamember is automatically named the same as the parent. E.g. Division X Risk Register Division X Risk Register Department A Risk Register Department B ...

Adding a Total column to MDX

I have the following query that gives me an extract (I am putting this into a CSV from my cube). I want to show the Total of all NRx in a column as the first column NRx and the rest of the NRx ...

using colors in calculated member

Im using this query in MDX for a calculate measure topcount(nonempty([StatusPlanes].[Status].Status.members,[Measures].[Planes]),1)(0).member_caption this will bring me this result Dimension1 ...

Using colors with MDX calculated measure

I m using this query in MDX for a calculated measure topcount(nonempty([StatusPlanes].[Status].Status.members,[Measures].[Planes]),1)(0).member_caption This will bring me this result Dimension1 ...

Calculated Member for Cumulative Sum

First some background: I have the typical Date dimension (similar to the one in the Adventure Works cube) and an Account dimension. In my fact table I have daily transaction amounts for the accounts. ...

What is MDX and what is its use in SAP BPC

I would like to know more about "MDX" (Multidimensional Expressions). What is it? What is it used for? Why would you use it? Is it better than SQL? What is its use in SAP BPS (I haven t seen BPC, ...

热门标签