SSAS Dimension attribute as Calculated Measure

浪子不回头ぞ 提交于 2019-12-22 10:44:28

问题


I am having some issues trying to implement an average of a dimension attribute.

The basic structure is:

  • Booking Header Dimension
  • Fact Table (multiple rows per Booking Header entry)

On the booking header dimension I have a numerical attribute called Booking Window, and I want to be able to create a calculated measure that averages this value.

We are using SQL Server 2012 standard edition.

Any help would be greatly appreciated.


回答1:


The best approach would be to create a measure group from the dimension table (in BIDS, go to cube designer, tab "Cube Structure", right-click the cube object in the Measures list, and select "New Measure Group", select your dimension table). BIDS will generate some measures, and you can remove all but two: the one based on your numeric attribute (I will call it "YourSummedAttrib" to have a name to refer to below), and the count measure. The aggregate function for the measure "YourSummedAttrib" will probably be "sum", leave that as it is.

Then, create a calculated measure which divides "YourSummedAttrib" by the count measure, which gives the average. Finally, if you have tested everything, make the two measures "YourSummedAttrib" and the count measure invisible before you give the cube to the users, as they only need to see the average, which is the calculated measure.




回答2:


You can try this which should give you the average of that attribute across all members.

WITH MEMBER [Measures].[Booking Window Value] AS
[Booking Header].[Booking Window].CURRENTMEMBER.MEMBER_VALUE
MEMBER [Measures].[Avg Booking Window Value] AS
AVG([Booking Header].[Booking Window].[Booking Window].MEMBERS,[Measures].[Booking Window Value])
SELECT
[Measures].[Avg Booking Window Value] ON COLUMNS
FROM
[YourCube]

Hope that helps and apologies for any confusion on my part.

Ash




回答3:


I tried to use the same idea, but without success. The solution I found was create a view with the calculated average and include a new group of measures.



来源:https://stackoverflow.com/questions/24122118/ssas-dimension-attribute-as-calculated-measure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!