Returns the average of the numeric function applied over the tuples of the set.
In our example we're calculating the average as ( 1.0 + 3.0 ) / ( 1 + 1), ignoring the empty value.
Query
WITH
MEMBER [Geography].[Geo].[1] AS 1.0
MEMBER [Geography].[Geo].[3] AS 3.0
MEMBER [Geography].[Geo].[Empty] AS Null
MEMBER [Measures].[Avg Amount] AS Avg( { [Geography].[Geo].[1],[Geography].[Geo].[3], [Geography].[Geo].[Empty] }, [Measures].[Amount] )
SELECT
[Measures].[Avg Amount] ON 0
FROM
[Sales]
Result
Assertion : MDX Equals
WITH
MEMBER [Measures].[Avg Amount] AS 2.0
SELECT
[Measures].[Avg Amount] ON 0
FROM
[Sales]
Returns the weighted average of the numeric function applied over the tuples of the set.
In our example we're calculating the weighted average with a constant weight of 2.
Query
WITH
MEMBER [Measures].[WAvg Amount] AS WAvg( [Geography].[Economy].members, 2, [Measures].[Amount] )
SELECT
[Measures].[WAvg Amount] ON 0
FROM
[Sales]
Result
Assertion : MDX Equals
WITH
MEMBER [Measures].[WAvg Amount] AS Avg( [Geography].[Economy].members, [Measures].[Amount] )
SELECT
[Measures].[WAvg Amount] ON 0
FROM
[Sales]
Returns the weighted average of the numeric function applied over the tuples of the set.
In our example we're calculating the weighted average with a variable weight.
Query
WITH
MEMBER [Measures].[WAvg Amount] AS WAvg( [Geography].[Economy].members, [Measures].[Amount] / 2, [Measures].[Amount] )
SELECT
[Measures].[WAvg Amount] ON 0
FROM
[Sales]
Result
WAvg Amount |
765.4802867383513 |
Assertion : MDX Equals
WITH
MEMBER [Measures].[weight] AS ( [Measures].[Amount] / 2)
MEMBER [Measures].[value] AS ( [Measures].[Amount] )
MEMBER [Measures].[WAvg Amount.1] AS Avg( [Geography].[Economy].members, [Measures].[weight]*[Measures].[value] )
MEMBER [Measures].[WAvg Amount.2] AS Avg( [Geography].[Economy].members, [Measures].[weight] )
MEMBER [Measures].[WAvg Amount] AS [Measures].[WAvg Amount.1] / [Measures].[WAvg Amount.2]
SELECT
[Measures].[WAvg Amount] ON 0
FROM
[Sales]