有条件的MDX查询以计算总和和平均值 [英] Conditional MDX Query to calculate sum and average
问题描述
我有一个销售(SalesID,GoodsType,GrossSale,AverageSale).我要在MS Visual Studio SSAS多维数据集的计算"选项卡中编写两个MDX表达式,以计算GoodsType为"Food"的GrossSale之和和GrossSale的平均值.如果有人请为我写MDX表达式?
I have a sales(SalesID, GoodsType, GrossSale, AverageSale). I was to write two MDX expression in MS Visual Studio SSAS cube's Calculation tab to calculate Sum of GrossSale and Average of GrossSale where GoodsType is "Food". If someone please write the MDX expression for me?
推荐答案
在许多情况下,您都依赖Analysis Services引擎来进行求和.要获取维度Dim
的属性DataType
的单个属性成员2
的度量值[GrossSales]
的总和,假设度量值配置为使用sum作为其聚合值,则可以在元组中引用它喜欢
In many cases, you rely on the Analysis Services engine to do the summing for you. To get the sum for the measure [GrossSales]
for a single attribute member 2
for attribute DataType
of dimension Dim
, assuming the measure is configured to use sum as its aggregation value, you can just reference it in a tuple like
([Dim].[DataType].[2], [Measures].[GrossSales])
完成. 要获得三个不同值的总和,您可以将两个元组求和,即. e.
and are done. To get the sum for three different values, you can either sum the tuples, i. e.
([Dim].[DataType].[1], [Measures].[GrossSales]) +
([Dim].[DataType].[2], [Measures].[GrossSales]) +
([Dim].[DataType].[3], [Measures].[GrossSales])
或按以下方式使用sum
函数:
or use the sum
function as follows:
Sum( { [Dim].[DataType].[1], [Dim].[DataType].[2], [Dim].[DataType].[3] },
[Measures].[GrossSales])
Sum
的第一个参数是集合,第二个参数是数字表达式.
The first argument for Sum
is a set, the second a numeric expression.
这篇关于有条件的MDX查询以计算总和和平均值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!