The ABS function calculates the absolute value of an expression. Since, the absolute value of a real number is its numerical value without regard to its sign (for example, 3 is the absolute value of both 3 and -3), this function always returns a positive value.
DECIMAL.
The dimensionality of the result is the same as the specified expression.
ABS(expression)
The expression whose absolute value is to be calculated.
Example 7-1 Finding Values in an Absolute Range
Suppose you are interested in how close your planned 1996 sales figures for sportswear in Boston were to the actual sales. You would like to see those months where budgeted figures are off by more than $5,000 in either direction. You can use ABS to help you find those months.
LIMIT product TO 'Sportswear' LIMIT district TO 'Boston' LIMIT month TO YEAR 'Yr96' LIMIT month KEEP ABS(sales - sales.plan) GT 5000 REPORT DOWN month sales sales.plan sales - sales.plan
These statements produce the following output.
DISTRICT: BOSTON ------------PRODUCT------------- -----------SPORTSWEAR----------- SALES - MONTH SALES SALES.PLAN SALES.PLAN -------------- ---------- ---------- ---------- Jun96 79,630.20 73,568.52 6,061.68 Jul96 95,707.30 80,744.18 14,963.12 Aug96 82,004.00 71,811.45 10,192.55 Sep96 89,988.60 78,282.07 11,706.53 Dec96 50,281.40 56,720.87 -6,439.47