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(timestamp), 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_command_lineTokenize a command-line string into a dynamic array of arguments.
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.
punycode_from_stringEncode a Unicode string into Punycode (the ACE form defined in RFC 3492).
punycode_to_stringDecode a Punycode (RFC 3492 ACE) string back to its Unicode form.
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.
ingestion_timeReturn the ingestion timestamp of the current row, as recorded by the nursery in the synthetic ingest_time column.
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_concatConcatenate dynamic arrays into a single dynamic array.
array_iffElement-wise select between two values based on a boolean-array condition.
array_index_ofReturn the zero-based index of the first occurrence of lookup in array, optionally starting at start_index.
array_lengthReturn the number of elements in an array.
array_reverseReturn a dynamic array with the elements in reverse order.
array_rotate_leftRotate a dynamic array by count positions to the left.
array_rotate_rightRotate a dynamic array by count positions to the right.
array_shift_leftShift the elements of a dynamic array by count positions to the left.
array_shift_rightShift the elements of a dynamic array by count positions to the right.
array_sliceReturn a contiguous subrange of array between inclusive start and inclusive end indices.
array_sort_ascSort a dynamic array in ascending order.
array_sort_descSort a dynamic array in descending order.
array_splitSplit a dynamic array at one or more indices.
array_sumSum the numeric elements of a dynamic array and return a real.
bag_has_keyReturn true if the property bag contains the given key.
bag_keysReturns an array of all the keys in a property bag (dynamic object).
bag_mergeMerge property bags into a single bag using first-wins collision resolution.
bag_packCreate a property bag (dynamic object) from key-value pairs.
bag_pack_columnsCreate a dynamic property bag whose keys are column names and whose values are the corresponding column values for the current row.
bag_remove_keysRemove specified keys from a property bag.
bag_set_keyReturn the property bag with the given key set to value, inserting or overwriting.
column_ifexistsIf a column named column_name exists in the current row set, return its value for the current row; otherwise evaluate and return default.
extract_dynamicExtract a value from a dynamic value using a JSONPath expression.
extract_jsonExtract a value from a JSON string using a JSONPath expression.
jaccard_indexReturn the Jaccard similarity |A ∩ B| / |A ∪ B| of two dynamic arrays treated as sets.
pack_allCreate a property bag containing all column values.
pack_arrayBuild a dynamic array from the given arguments, in order.
parse_jsonParse a JSON string into a dynamic value.
rangeGenerates an array of values in a specified range.
repeatBuild a dynamic array by repeating value count times.
set_differenceReturn the distinct elements of the first dynamic array that are not present in any of the remaining arrays, preserving first-seen order.
set_has_elementReturn true if value exists in the dynamic array.
set_intersectReturn the distinct elements that appear in every dynamic array argument, preserving first-seen order from the first array.
set_unionReturn the distinct elements from all dynamic-array arguments, preserving first-seen order.
treepathEnumerate the JSON paths (in bracket notation) reachable inside a dynamic value.
zipZip two or more dynamic arrays element-wise.

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).
beta_cdfRegularised incomplete-beta CDF of Beta(α, β) at x.
beta_invInverse CDF (quantile) of Beta(α, β) at probability p.
beta_pdfProbability density of Beta(α, β) at x.
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.
bitset_count_onesReturn the number of set bits in the two's-complement representation of an integer.
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.
erfError function erf(x) = (2/√π) ∫₀ˣ e^{-t²} dt.
erfcComplementary error function erfc(x) = 1 - erf(x).
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.
gammaGamma function Γ(x).
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.
loggammaNatural log of the absolute value of the gamma function, equivalent to lgamma(x) in C99.
max_ofReturn the maximum of 2 to 64 comparable arguments.
min_ofReturn the minimum of 2 to 64 comparable arguments.
piReturns the constant value of Pi.
powReturns the value raised to the specified power.
radiansConverts degrees to radians.
randReturn a pseudo-random real.
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.
welch_testTwo-tailed p-value for the Welch unequal-variances t-test given the mean, variance, and count of each of two samples.

Type Functions

FunctionDescription
estimate_data_sizeEstimates the data size in bytes for the specified columns.
gettypeReturn the runtime type of a value as a string.
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_acosApply acos element-wise to a numeric dynamic series.
series_addElement-wise addition of two numeric series.
series_asinApply asin element-wise to a numeric dynamic series.
series_atanApply atan element-wise to a numeric dynamic 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_cosApply cos element-wise to a numeric dynamic series.
series_cosine_similarityCosine similarity (a·b)/(|a|·|b|) of two equal-length numeric series.
series_decomposeDecompose a numeric time series into baseline, seasonal, trend, and residual components.
series_decompose_anomaliesDetects anomalies in a time series using decomposition and outlier detection.
series_decompose_forecastExtend a numeric time series forward by points samples by decomposing into trend + seasonal components and extrapolating both.
series_divideElement-wise division of two numeric series.
series_dot_productDot product Σ aᵢ·bᵢ of two equal-length 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_2lines_dynamicPiecewise-linear best fit of a numeric series with change-point search.
series_fit_lineFit a line to the series using linear regression.
series_fit_line_dynamicClosed-form ordinary-least-squares fit of a numeric series, returned as a property bag shaped like Microsoft Kusto's output: { slope, interception, rsquare, variance, rvariance, line_fit: [...] }
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_magnitudeEuclidean L2 norm of a numeric series - sqrt of the sum of squares.
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_productProduct of all elements in the series (real).
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_sinApply sin element-wise to a numeric dynamic series.
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.
series_tanApply tan element-wise to a numeric dynamic series.

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.
otel_histogram_percentileExtract a percentile from a merged OpenTelemetry histogram (output of otel_histogram_merge).
percentile_array_tdigestExtract a dynamic array of percentiles from a sketch aggregate produced by tdigest().
percentile_tdigestCalculate the percentile from a t-digest representation.
percentrank_tdigestReturn the approximate percentile rank of value in a t-digest / DDSketch sketch produced by the tdigest() aggregate.
rank_tdigestReturn the approximate count of items ≤ value in a t-digest / DDSketch sketch produced by the tdigest() aggregate.
row_numberReturns the current row number in the serialized row set.

On this page