Skip to main content
The series_divide function performs element-wise division between two dynamic arrays (series) of numeric values. It divides corresponding elements from the first array by the corresponding elements in the second array and returns a new array containing the results. This function is useful when you need to calculate ratios, normalize data, or perform proportional analysis across time-series datasets. You can use series_divide when you want to calculate rates, percentages, or ratios between different metrics. Common applications include calculating success rates, determining resource utilization ratios, computing performance improvements, and normalizing metrics for comparison across different scales.

For users of other query languages

If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.
In Splunk SPL, you typically use the eval command with the division operator to divide values. However, dividing arrays element-wise requires more complex operations. In APL, series_divide directly performs element-wise division on dynamic arrays.
... | eval ratio = field1 / field2
In SQL, you divide individual values using the / operator, but there’s no built-in function for element-wise array division. You would need to unnest arrays and perform complex operations. In APL, series_divide handles this operation directly on dynamic arrays.
SELECT value1 / value2 AS ratio
FROM my_table;

Usage

Syntax

series_divide(array1, array2)

Parameters

ParameterTypeDescription
array1dynamicThe numerator dynamic array of numeric values.
array2dynamicThe denominator dynamic array of numeric values.

Returns

A dynamic array where each element is the result of dividing the corresponding element from array1 by the corresponding element from array2. If the arrays have different lengths, the result array has the length of the shorter array. Division by zero returns infinity or negative infinity.

Use case examples

  • Log analysis
  • OpenTelemetry traces
  • Security logs
In log analysis, you can use series_divide to calculate success rates by dividing successful requests by total requests for each time period.Query
['sample-http-logs']
| summarize successful_requests = make_list(iff(status == '200', 1, 0)), total_requests = make_list(1) by id
| extend success_rates = series_divide(successful_requests, total_requests)
Run in PlaygroundOutput
idsuccessful_requeststotal_requestssuccess_rates
u123[1, 0, 1][1, 1, 1][1, 0, 1]
u456[1, 1][1, 1][1, 1]
This query calculates success rates by dividing successful requests by total requests for each user.
  • series_abs: Returns the absolute value of each element in an array. Use when you need to remove negative signs without rounding.
  • series_add: Performs element-wise addition between two arrays. Use when you need to combine values instead of calculating ratios.
  • series_cosine_similarity: Calculates cosine similarity between two arrays. Use when you need normalized similarity measures rather than raw dot products.
  • series_dot_product: Calculates the dot product between two arrays. Use when you need the raw dot product value rather than normalized similarity.
  • series_sum: Calculates the sum of all elements in a single array. Use when you need to sum elements within one array rather than computing dot products.