# Custom formula

Perform basic calculations on your column, or combine one or more of our formulas as needed. SQLite functions are also supported. See the SQLite documentation for the full list of core functions, aggregate functions, and date and time functions available.

## Common functions

Name Formula
Moving average moving_avg(“Column name”, # trailing rows)
Running total running_total(“Column name”)
Percent change percent_change(“Column name”)
Median median(“Column name”)
Format format(“Column name”, format string)
Lag lag(“Column name”, offset)
Average avg(“Column name”)
Round round(“Column name”, # decimals)
Coalesce coalesce(“Column name”, replacement char)
Cast cast(“Column name” as datatype)

## Math functions

acos, asin, atan, atn2, atan2, acosh, asinh, atanh, difference, degrees, radians, cos, sin, tan, cot, cosh, sinh, tanh, coth, exp, log, log10, power, sign, sqrt, square, ceil, floor, pi

## String functions

replicate, charindex, leftstr, rightstr, ltrim, rtrim, trim, replace, reverse, proper, padl, padr, padc, strfilter

## Aggregate functions

stdev, variance, mode, median, lower_quartile, upper_quartile

## Date functions

In the formulas below, units can be one of the following: day, month, year, hour, minute, second, quarter (datepart() only), dayofyear (datepart() only). For more details on these date functions, check out Date and Datetime functions in the Data Pipeline page.

Name Formula
Date add dateadd( date_string, amount, ‘unit’ )
Date subtract datesub( date_string, amount, ‘unit’ )
Date difference datediff( date_string1, date_string2, ‘unit’ (optional) )
Date part datepart( date_string, ‘unit’ )