Skip to content

abs - Take absolute value of a number

Returns the absolute value of number. Useful for computing the total difference between two values.

Syntax

Like many functions in DataPrime, abs supports two notations, function and method notation. These interchangeable forms allow flexibility in how you structure expressions.

abs(number: number): number
number: number.abs(): number

Arguments

NameTypeRequiredDescription
numbernumbertrueThe value which will be made positive

Example: The difference between two timestamp fields

In this example, a new field is made called time_difference that is populated by the numerical difference between a field first_timestamp and second_timestamp. The use of the abs function means the user doesn't need to know which timestamp is greater.

source logs | create time_difference from abs(first_timestamp - second_timestamp)
source logs | create time_difference from (first_timestamp - second_timestamp).abs()