Abs function (MDX)

The Abs function returns the absolute value of a numeric argument.

Returns: A number.

Syntax

Read syntax diagramSkip visual syntax diagram
>>-Abs--(--NumericExpression--)--------------------------------><

Parameters

NumericExpression
Specifies the numeric value whose absolute value is to be returned.

Example

In this example, you want to evaluate years that had below-average profit. The following query uses the Abs function to return the profit amount and the amount below the average profit for below-average years.

Query
WITH 
MEMBER [Price Analysis].[Measures].[Average Profit Amount] 
	AS Avg( [Price Analysis].[Time].CurrentMember.Siblings, 
          [Price Analysis].[Measures].[Profit Amount] )
MEMBER [Price Analysis].[Measures].[Amount Below Average] 
	AS Abs(  ([Price Analysis].[Time].CurrentMember, 
            [Price Analysis].[Measures].[Profit Amount])
         - ([Price Analysis].[Time].CurrentMember, 
            [Price Analysis].[Measures].[Average Profit Amount]) )
SELECT { [Price Analysis].[Measures].[Profit Amount], 
         [Price Analysis].[Measures].[Amount Below Average] } 
	ON AXIS(0), 
       { Filter( [Price Analysis].[Time].[All Time (Calendar)].Children, 
                 ([Price Analysis].[Time].CurrentMember, 
                  [Price Analysis].[Measures].[Profit Amount]) 
                    < ([Price Analysis].[Time].CurrentMember, 
                  [Price Analysis].[Measures].[Average Profit Amount]) ) } 
	ON AXIS(1) 
FROM [Price Analysis] 
Result
Time Profit amount Amount below average
2002 263524.08 10525.747
2003 255214.96 18834.867


Feedback | Information roadmap