Skip to main content
Use the pow function in APL to raise a base value to a given exponent: base^exponent. The function accepts any real base and exponent. pow is useful whenever you need to apply a power function to a metric, such as squaring deviations for variance calculations, computing exponential growth factors, scaling values by a fractional power, or inverting a power transformation. It’s more flexible than exp, exp2, or exp10 because you can specify any base.

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, pow(base, exponent) works identically to APL’s pow. You can also use the ^ operator for the same purpose.
| eval squared = pow(req_duration_ms, 2)
In ANSI SQL, POWER(base, exponent) provides the same functionality as APL’s pow.
SELECT POWER(req_duration_ms, 2) AS squared FROM logs

Usage

Syntax

pow(base, exponent)

Parameters

NameTypeRequiredDescription
baserealYesThe base value.
exponentrealYesThe exponent to raise the base to.

Returns

base raised to the power exponent: base^exponent.

Example

Use pow to square the deviation of each request’s duration from a 200 ms baseline. Query
['sample-http-logs']
| extend deviation = req_duration_ms - 200.0
| extend squared_deviation = pow(deviation, 2)
| project _time, id, req_duration_ms, squared_deviation
| order by squared_deviation desc
Run in Playground Output
_timeidreq_duration_mssquared_deviation
2024-11-14 10:00:00user-11200.01000000.0
2024-11-14 10:01:00user-280.014400.0
2024-11-14 10:02:00user-3205.025.0
  • sqrt: Returns the square root of a value. This is equivalent to pow(x, 0.5) and is more readable for the square-root case.
  • exp: Returns e^x. Use it when the base is e rather than an arbitrary number.
  • exp2: Returns 2^x. Use it when the base is always 2.
  • exp10: Returns 10^x. Use it when the base is always 10.
  • log: Returns the natural logarithm. Use it to undo a pow transformation in log space.