How to multiply two measures prior to aggregation

浪子不回头ぞ 提交于 2019-12-25 03:27:25

问题


I have two measures. The first is amount, and the second consist of values -1,0 and 1, so table looks like this:

Amount   Sign
--------------
400      -1
200       1
300       0

Result I want to get is 400*(-1) + 200*1 + 300*0 = -200, but I am getting (400+200+300)*(-1+1+0) = 0

This is my calculated member:

WITH 
  MEMBER [Measures].[Result]
  AS
[Measures].[Sign]*[Measures].[Amount]
select 
[Measures].[Result] on 0,
[Time].[Time].members on 1
from [MyCube]

回答1:


In you SSAS project, go to the datasource view, for the underlying fact table add a NamedCalculation. In that do the multiplication that you explained. Now in the Cube add that as a measure. It will behave exactly like you want it to behave.



来源:https://stackoverflow.com/questions/53554284/how-to-multiply-two-measures-prior-to-aggregation

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