我有一个包含以下数据的事实模型:
WorkOrderNumber | WorkOrderLineNumber | Cost
所以我有一个维度WorkOrder:
[WorkOrder].[WorkOrderNumber]
[WorkOrder].[WorkOrderLineNumber]
具有以下测量的测量组:
[Measures].[Cost]
我正在尝试创建一个计算度量:
[Measures].[Average WorkOrder Cost]
这必须通过总结每个工作订单的价值并随后计算每个工作人员的所有这些总和的平均值来计算。
但是我似乎无法让它发挥作用。
CASE WHEN [WorkOrder].[WorkOrder].CurrentMember = [WorkOrder].[WorkOrder].[All]
THEN
/* the work order is not selected -> AVG*/
DIVIDE(SUM(),[Measures].[Cost]), Count()) ))
ELSE
/* the Work Order is selected -> SUM*/
SUM([Measures].[Cost])
END
答案 0 :(得分:0)
以下是使用Adventure Works多维数据集获取每个销售订单的平均值的示例。您可以替换为[Cost]和[WorkOrderNumber] ......
with member [CalculatedAvg] as
AVG([Internet Sales Order Details].[Sales Order Number].[Sales Order Number], [Measures].[Internet Sales Amount])
, FORMAT_STRING = "$#,##0.00"
select
{
[Measures].[Internet Sales Amount],
[Measures].[Internet Order Count],
[Measures].[Internet Average Sales Amount],
[CalculatedAvg]
} on 0,
[Date].[Calendar].[Calendar Year].members on 1
from
[Direct Sales]
例如......
AVG([WorkOrder].[WorkOrderNumber].[WorkOrderNumber], [Measures].[Cost])