# Math Functions

A math function performs mathematical calculations. Use Math functions with Numeric data types only.

## ABS

ABS(x): Returns the absolute value of a number (x). It's the distance between 0 and a number. The value is always positive.

### Example

• ABS(32) returns 32.

• ABS(–32) returns 32.

## ACOS

ACOS(x): Returns the arccosine, or inverse cosine, of a number (x). The arccosine is the angle whose cosine is (x).

• The returned angle is given in radians in the range 0 (zero) to pi.

• The number (x) must be between -1 and 1.

### Example

ACOS(0.5) returns 1.047198.

## ASIN

ASIN(x): Returns the arcsine, or inverse sine, of a number (x). The arcsine is the angle whose sine is (x).

• The returned angle is given in radians in the range -pi/2 to pi/2.

• The number (x) must be between -1 and 1.

### Example

ASIN(0.5) returns 0.523599.

## ATAN

ATAN(x): Returns the arctangent, or inverse tangent, of a number (x). The arctangent is the angle whose tangent is (x). The returned angle is given in radians in the range -pi/2 to pi/2.

### Example

ATAN(0.8) returns 0.674741.

## ATAN2

ATAN2(y, x): Returns the arctangent, or inverse tangent, of y and x (Arc - Tangent of (y/x)).

### Example

ATAN2(4, –3) returns 2.2143.

## Average

Average(n1, ...): Returns the average of a list of numbers. NULL values are treated as 0 and taken into consideration in the calculation of the average value.

### Example

Average(20,30,55) returns 35 since [(20+30+55)/3]= 35.

## AverageNonNull

AverageNonNull(n1, ...): Returns the average of a list of numbers. Null values are excluded from the calculation. The calculation only works with Numeric data types.

Note

Please note that the AverageNonNull function works differently than the above Average(n1, …) function.

• AverageNonNull excludes null values from the average calculation. This is the same behavior as the Average Action available via the Summarize tool.

• Average treats null values as 0's.

Because of this, the 2 functions can return different results depending on the input.

### Example

• AVERAGENONNULL(Null, 1, 1) returns 1 (vs. 0.666666666666667 with the Average function, which includes Null as 0).

• AVERAGENONNULL(Null, 1, 2, 3) returns 2 (vs. 1.5 with the Average function).

• AVERAGENONNULL(Null, 1, 2, 2) returns 1.666666666666667 (vs. 1.25 with the Average function).

• AVERAGENONNULL(Null, 1.2, 2.345, 3.456789) returns 2.33392966666667 (vs. 1.75044725 with the Average function).

• AVERAGENONNULL(Null, 1.2, 2.345, 3.456789, Null) returns 2.33392966666667 (vs. 1.4003578 with the Average function).

• AVERAGENONNULL(Null, Null, Null) returns Null. When all values are Null, the results are Null.

## CEIL

CEIL(x, [mult]): Returns a numeric value (x) raised to the lowest multiple of (mult) that is greater than or equal to x. The (mult) parameter must be a number greater than 0. If (mult) is not specified, the function returns the smallest integer greater than or equal to (x).

Note

CEIL(x) changes double to Int64 value if the value is within INT64 range, else it returns double.

### Example

• CEIL(9.567) returns 10 (if we don't provide a parameter, the function defaults to return the smallest integer greater than or equal to x).

• CEIL(123.456, 10) returns 130 (rounds up to the nearest multiple of 10).

• CEIL(–110, 100) returns -100 (rounds up to the nearest multiple of 100).

• CEIL(123, Null) returns Null (If there is a null in any parameter, the result is Null).

• CEIL(9.123, 0.01) returns 9.13 (rounds up to the nearest multiple of .01).

• CEIL(7, 5) returns 10 (rounds up to the nearest multiple of 5).

## COS

COS(x): Returns the cosine of a given angle (x). x must be in radians.

### Example

COS(1) returns 0.54030230586814.

## COSH

COSH(x): Returns the hyperbolic cosine of a number (x).

### Example

COSH(1) returns 0.54030230586814.

## DISTANCE

DISTANCE(from_Lat,from_Lon, to_Lat, to_Lon): Returns the distance from (lat1,Lon1) to (lat2,lon2).

### Example

DISTANCE(42, –90, 43, –80) returns a value of 513.473706 miles.

## EXP

EXP(x): Returns the constant e raised to the power of an exponent (x) (e^x).

## FACTORIAL

FACTORIAL(x): Returns the factorial of a numeric value (x) via the (n! = n x (n–1) x … x 1) calculation. For example, the factorial of 4 is calculated as such: 4! = 4 x 3 x 2 x 1 = 24.

• This function accepts positive integers only.

• This function doesn't support decimal numbers.

• Due to numeric data type size limitations, the maximum allowable value for (x) in the Factorial function is 170.

Note

While the mathematical representation of factorial is commonly denoted as x!, the Alteryx function only recognizes factorial via Factorial(x).

### Example

• FACTORIAL(0) returns 1.

• FACTORIAL(1) returns 1.

• FACTORIAL(Null) returns Null.

• FACTORIAL(5) returns 120 (5 * 4 * 3 * 2 * 1).

• FACTORIAL(8) returns 40320 (8 * 7 * 6 * 5 * 4 * 3 * 2 * 1).

## FLOOR

FLOOR(x, [mult]): Returns a numeric value (x) lowered to the highest multiple of (mult) that is less than or equal to x. The (mult) parameter must be a number greater than 0. If (mult) is not specified, the function returns the largest integer less than or equal to (x), as shown in the first example below.

Note

FLOOR(x) changes double to Int64 value if the value is within INT64 range, else it returns double.

### Example

• FLOOR(4.567) returns 4 (if you don't provide a parameter, the function defaults to return the largest integer less than or equal to x).

• FLOOR(4.567, 0.01) returns 4.56 (rounds down to the nearest hundredth).

• FLOOR(–15.75, 0.1) returns –15.8 (rounds down to the nearest tenth).

• FLOOR(Null, 10) returns Null (If there is a null in any parameter, the result is Null).

• FLOOR(13, 5) returns 10 (rounds down to 10, which is the nearest multiple of 5 that is less than or equal to 13).

## LOG

LOG(x): Returns the natural logarithm of a number (x). x should be a positive number.

### Example

• LOG(1) returns 0.

• LOG(14) returns 2.639057.

## LOG10

LOG10(x): Returns the base-10 logarithm of a number (x). x should be a positive number.

### Example

• LOG10(1) returns 0.

• LOG10(14) returns 1.146128.

## Median

Median(...): Calculates the median of 1 or more (possibly unsorted) values.

### Example

Median (5, 4, 3, 7, 6) returns 5.

## Mod

Mod(n,d): Modulo of a number (n) divided by a number (d) (integer operation).

The Modulo operation finds the remainder of 1 integer (n) divided by a divisor integer (d).

• If (n) is positive, the result is positive.

• If (n) is negative, the result is negative.

If you use decimal values, the decimal is truncated. This can result in a "Divided by 0" error if the divisor is a decimal less than 1.

### Example

• MOD(6,4) returns 2.

• MOD(6,–4) returns 2.

• MOD(–6,4) returns –2.

• MOD(–6,–4) returns –2.

• MOD(6,.4) returns [Null].

## PI

PI(): Returns the value of the constant PI to 15 digits of accuracy.

### Example

PI() returns 3.141593.

## POW

POW(x, e): Returns a number (x) raised to the (e) power.

### Example

POW(2, 3) is equivalent to 23 and returns 8.

## RAND

RAND(): Returns a random number greater than or equal to 0 and less than 1.

### Example

RAND() returns a random number like 0.256.

## RandInt

RandInt(n): Returns a random integer between 0 and the specified parameter (n).

### Example

• RandInt(10) returns 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 or 10.

• RandInt(5000) returns a random whole number between 0 and 5000, like 741.

## Round

Round(x, mult): Returns a number (x) rounded to the nearest multiple of (mult).

Note

The rounding is done after dividing the number (x) by mult. If that result is negative (and is exactly an integer plus a half), the function rounds up instead of rounding away from zero. After it rounds to an integer, it multiplies again by the mult.

### Example

• Round(55.34, 2) returns a value of 56.

• Round(39.88, 10) returns a value of 40.

• Round(41.1, 10) returns a value of 40.

• Round(1.25, 0.1) returns a value of 1.3.

• Round(1.227, 0.01) returns a value of 1.23.

• Round(–25, –10) returns a value of -30.

• Round(–25, 10) returns a value of –20.

• Round(–1.5, 1) returns a value of –1.

• Round(15, 10) returns a value of 20.

• Round(–15, 10) returns a value of –10.

• Round(15, –10) returns a value of 10.

• Round(–15, –10) returns a value of –20.

## SIN

SIN(x): Returns the sine of a given angle (x). x must be in radians.

### Example

SIN(90) returns 0.893996663600558.

## SINH

SINH(x): Returns the hyperbolic sine of a number (x).

## SmartRound

SmartRound(x): Returns a number (x) rounded to the nearest multiple of a value determined dynamically based on the size of (x).

## SQRT

SQRT(x): Returns the square root of a number (x).

### Example

SQRT(100) returns a value of 10.

## TAN

TAN(x): Returns the tangent of a given angle (x). x must be in radians.

### Example

TAN(1) returns 1.5574077246549.

## TANH

TANH(x): Returns the hyperbolic tangent of a number (x).

### Example

TANH(90) returns 1.