Berserk Docs
Scalar Functions

Introduction to Scalar Functions

Scalar function overview and categories

Scalar functions take one or more values and return a single value. Use them in project, extend, and where expressions to transform or compute values per row:

logs
| extend hour = hourofday($time), msg = tolower(body)
| where strlen(msg) > 100

For a full introduction to writing queries, see Writing Queries.

String Functions

FunctionDescription
containsIndicate whether a string contains another string (case-insensitive).
contains_csIndicate whether a string contains another string (case-sensitive).
countofCounts occurrences of a substring in a string.
endswithIndicate whether a string ends with another string (case-insensitive).
endswith_csIndicate whether a string ends with another string (case-sensitive).
extractExtracts a match for a regular expression from a string.
extract_allExtracts all matches for a regular expression from a string.
hasIndicate whether a string contains a whole word (case-insensitive, word boundary matching).
has_any_indexReturns the index of the first matching value in the source string.
has_csIndicate whether a string contains a whole word (case-sensitive, word boundary matching).
hasprefixIndicate whether a string starts with a word prefix (case-insensitive, word boundary matching).
hasprefix_csIndicate whether a string starts with a word prefix (case-sensitive, word boundary matching).
hassuffixIndicate whether a string ends with a word suffix (case-insensitive, word boundary matching).
hassuffix_csIndicate whether a string ends with a word suffix (case-sensitive, word boundary matching).
indexofReturns the zero-based index of the first occurrence of a substring.
matches regexReturns true if the string matches the regular expression pattern.
parse_urlParses a URL string and returns a dynamic object with URL components.
parse_urlqueryParses a URL query string and returns a dynamic object.
parse_versionConverts a version string to a comparable decimal number.
replace_regexReplaces all regex matches with another string.
replace_stringReplaces all occurrences of a string with another string.
replace_stringsReplaces multiple string pairs in the source.
reverseReverses the input string.
splitSplits a string by a delimiter and returns an array.
startswithIndicate whether a string starts with another string (case-insensitive).
startswith_csIndicate whether a string starts with another string (case-sensitive).
strcatConcatenates between 1 and 64 arguments.
strcat_arrayConcatenates array elements into a string using the specified delimiter.
strcat_delimConcatenates strings with a delimiter.
strcmpCompares two strings and returns -1, 0, or 1.
strlenReturns the length of the input string in characters.
strrepRepeats a string a specified number of times.
substringExtracts a substring from the source string starting at the specified position.
tolowerConverts a string to lower case.
toupperConverts a string to upper case.
translateReplaces characters in a string based on character mapping.
trimRemoves leading and trailing match of the specified regex from the source string.
trim_endRemoves trailing match of the specified regex from the source string.
trim_startRemoves leading match of the specified regex from the source string.
url_decodeURL-decodes a string.
url_encodeURL-encodes a string.

Date & Time Functions

FunctionDescription
agoSubtracts the given timespan from the current query timestamp.
datetime_addAdds a specified amount to a datetime value.
datetime_diffReturns the difference between two datetime values.
datetime_local_to_utcConverts a local datetime to UTC.
datetime_partExtracts the specified part from a datetime value.
datetime_utc_to_localConverts a UTC datetime to local time.
dayofmonthExtracts the day of month (1-31) from a datetime value.
dayofweekReturns the timespan since the preceding Sunday.
dayofyearExtracts the day of year (1-366) from a datetime value.
endofdayReturns the end of the day for the given datetime.
endofmonthReturns the end of the month for the given datetime.
endofweekReturns the end of the week for the given datetime.
endofyearReturns the end of the year for the given datetime.
format_datetimeFormats a datetime value as a string.
format_timespanFormats a timespan value as a string.
getyearExtracts the year from a datetime value.
hourofdayExtracts the hour (0-23) from a datetime value.
make_datetimeCreates a datetime value from components.
make_timespanCreates a timespan value from components.
monthofyearExtracts the month (1-12) from a datetime value.
nowReturns the current query timestamp as a datetime value.
startofdayReturns the start of the day for the given datetime.
startofmonthReturns the start of the month for the given datetime.
startofweekReturns the start of the week for the given datetime.
startofyearReturns the start of the year for the given datetime.
todatetimeConvert the input to a datetime.
totimespanConvert the input to a timespan.
unixtime_microseconds_todatetimeConverts Unix time in microseconds to a datetime value.
unixtime_milliseconds_todatetimeConverts Unix time in milliseconds to a datetime value.
unixtime_nanoseconds_todatetimeConverts Unix time in nanoseconds to a datetime value.
unixtime_seconds_todatetimeConverts Unix time in seconds to a datetime value.
weekofyearExtracts the ISO week number (1-53) from a datetime value.

Dynamic / JSON Functions

FunctionDescription
array_lengthReturn the number of elements in an array.
bag_keysReturns an array of all the keys in a property bag (dynamic object).
bag_packCreate a property bag (dynamic object) from key-value pairs.
bag_remove_keysRemove specified keys from a property bag.
extract_dynamicExtract a value from a dynamic value using a JSONPath expression.
extract_jsonExtract a value from a JSON string using a JSONPath expression.
pack_allCreate a property bag containing all column values.
parse_jsonParse a JSON string into a dynamic value.
rangeGenerates an array of values in a specified range.

Math Functions

FunctionDescription
absReturns the absolute value of a numeric expression, preserving the input type.
acosReturns the arc cosine of the input (in radians).
asinReturns the arc sine of the input (in radians).
atanReturns the arc tangent of the input (in radians).
atan2Returns the angle (in radians) between the positive x-axis and the point (x, y).
binRound values down to a bin of a given bin size.
bin_atRound values down to a bin of a given size relative to a fixpoint.
bin_autoAutomatically bins datetime values into human-friendly intervals based on the query time range.
ceilingCalculates the smallest integer greater than, or equal to, the specified numeric expression.
cosReturns the cosine of the input angle in radians.
cotReturns the cotangent of the input angle in radians.
degreesConverts radians to degrees.
expReturns e raised to the power of the numeric expression.
exp10Returns 10 raised to the power of the numeric expression.
exp2Returns 2 raised to the power of the numeric expression.
floorRounds values down to a fixed-size bin.
isfiniteReturns whether the input is a finite value (not infinity and not NaN).
isinfReturns whether the input is an infinite value (positive or negative infinity).
isnanReturns whether the input is NaN (Not a Number).
logReturns the natural logarithm of the numeric expression.
log10Returns the base-10 logarithm of the numeric expression.
log2Returns the base-2 logarithm of the numeric expression.
powReturns the value raised to the specified power.
radiansConverts degrees to radians.
roundReturns the rounded number to the specified precision.
signReturns the sign of a numeric expression (-1, 0, or 1), preserving the input type.
sinReturns the sine of the input angle in radians.
sqrtReturns the square root of the numeric expression.
tanReturns the tangent of the input angle in radians.

Type Functions

FunctionDescription
estimate_data_sizeEstimates the data size in bytes for the specified columns.
isemptyReturns true if the argument is an empty string or is null.
isnotemptyReturns true if the argument is not an empty string and is not null.
isnotnullReturns true if the value is not null.
isnullReturns true if the value is null.
new_guidReturns a random GUID string.
to_numericExtract numeric value from dynamic or pass through numeric types.
toboolConvert the input to a boolean.
todoubleConvert the input to a floating point number.
toguidValidates and normalizes a string as a GUID.
tohexConverts a number to a hexadecimal string.
tointConvert the input to a 32-bit integer.
tolongConvert the input to a 64-bit integer.
tostringConvert the input to a string.

IP Address Functions

FunctionDescription
parse_ipv4Converts an IPv4 string to a long number.
parse_ipv4_maskConverts an IPv4 string and netmask to a long number.
parse_ipv6Converts an IPv6 string to a canonical string representation.
parse_ipv6_maskConverts an IPv6 string and netmask to a canonical string representation.

Encoding Functions

FunctionDescription
base64_decode_toarrayDecodes a base64 string to an array of long values.
base64_decode_toguidDecodes a base64 string to a GUID.
base64_decode_tostringDecodes a base64 string.
base64_encode_fromguidEncodes a GUID to base64.
base64_encode_tostringEncodes a string to base64.

Series Functions

FunctionDescription
series_absCalculates the absolute value of each element in a numeric series.
series_addElement-wise addition of two numeric series.
series_avgReturns the average (mean) of all elements in a numeric series, ignoring null values.
series_ceilingRounds each element up to the nearest integer.
series_decompose_anomaliesDetects anomalies in a time series using decomposition and outlier detection.
series_divideElement-wise division of two numeric series.
series_equalsElement-wise equality comparison of two series.
series_expCalculates the exponential (e^x) of each element.
series_fftCompute the Fast Fourier Transform of a series.
series_fill_backwardFills missing values in a series by propagating the next valid value backward.
series_fill_constFills missing values in a series with a constant value.
series_fill_forwardFills missing values in a series by propagating the previous valid value forward.
series_fill_linearFills missing values in a series using linear interpolation.
series_firApplies a Finite Impulse Response (FIR) filter to a series.
series_fit_2linesFit two lines (piecewise linear) to the series.
series_fit_lineFit a line to the series using linear regression.
series_fit_polyApplies polynomial regression to a series, fitting a curve of the specified degree.
series_floorRounds each element down to the nearest integer.
series_greaterElement-wise greater-than comparison of two series.
series_greater_equalsElement-wise greater-than-or-equal comparison of two series.
series_ifftCompute the Inverse Fast Fourier Transform.
series_iirApplies an Infinite Impulse Response (IIR) filter to a series.
series_lessElement-wise less-than comparison of two series.
series_less_equalsElement-wise less-than-or-equal comparison of two series.
series_logCalculates the natural logarithm of each element.
series_maxReturns the maximum value in a numeric series, ignoring null values.
series_minReturns the minimum value in a numeric series, ignoring null values.
series_multiplyElement-wise multiplication of two numeric series.
series_not_equalsElement-wise inequality comparison of two series.
series_outliersDetects outliers in a series using the Tukey fence method.
series_pearson_correlationCalculate the Pearson correlation coefficient between two series.
series_periods_detectDetects periodic patterns in a time series using FFT-based spectral analysis.
series_periods_validateValidates expected periods in a time series using FFT spectral analysis.
series_powElement-wise power operation (base^exponent) of two numeric series.
series_seasonalCalculates the seasonal component of a series using median of values at same phase.
series_signReturns the sign of each element (-1 for negative, 0 for zero, 1 for positive).
series_statsComputes statistics (min, max, avg, stdev, variance) for a numeric series.
series_stats_dynamicComputes statistics for a numeric series and returns as a property bag.
series_stdevReturns the population standard deviation of all elements in a numeric series, ignoring null values.
series_subtractElement-wise subtraction of two numeric series.
series_sumReturns the sum of all elements in a numeric series, ignoring null values.

Conditional Functions

FunctionDescription
caseEvaluates predicates in order and returns the first matching value.
coalesceReturns the first non-empty value (not null and not empty string).
iffEvaluates the predicate and returns value_if_true or value_if_false.

Logging Functions

FunctionDescription
extract_log_templateNormalizes a string into a structural template by replacing variable tokens (numbers, UUIDs, IPs, hex values, quoted strings) with typed placeholders.
log_template_hashComputes a hash of the structural log template, for grouping similar logs without allocating the template string.
log_template_regexGenerates a regex pattern that matches log lines with the same structural template.

Other Functions

FunctionDescription
current_tableReturns the table name for the current row.
dcount_hllCalculate the distinct count from an HLL representation.
percentile_tdigestCalculate the percentile from a t-digest representation.
row_numberReturns the current row number in the serialized row set.

On this page