isfinite
isfinite is essential for data quality checks. Division by zero, logarithm of a non-positive number, or other edge cases can produce infinity or NaN in your computed columns. Use isfinite to identify or filter these invalid values before aggregating or visualizing data.
Usage#
Syntax#
isfinite(x)Parameters#
| Name | Type | Required | Description |
|---|---|---|---|
x |
real | Yes | The numeric value to check. |
Returns#
true if x is a finite real number (not infinity and not NaN). false otherwise.
Example#
Use isfinite to check whether a computed value is finite before using it in aggregations.
Query
['sample-http-logs']
| extend log_duration = log(req_duration_ms)
| extend is_valid = isfinite(log_duration)
| project _time, id, req_duration_ms, log_duration, is_validOutput
| _time | id | req_duration_ms | log_duration | is_valid |
|---|---|---|---|---|
| 2024-11-14 10:00:00 | user-1 | 120.0 | 4.7875 | true |
| 2024-11-14 10:01:00 | user-2 | 0.0 | -inf | false |
| 2024-11-14 10:02:00 | user-3 | 80.0 | 4.3820 | true |
List of related functions#
- isinf: Returns
trueonly for infinite values. Use it when you want to distinguish infinity from NaN. - isnan: Returns
trueonly for NaN values. Use it when you want to detect only Not-a-Number results. - isint: Returns
truefor integer values. Use it to check whether a numeric value is an integer rather than a floating-point result. - log: Returns the natural logarithm. Combine with
isfiniteto validate log computations on potentially non-positive inputs. - gamma: Returns the gamma function. Use
isfiniteto filter out overflow results when computinggammaon large values.
Other query languages#
Splunk SPL users
Splunk SPL doesn't have a direct isfinite() function. You typically check for null or use isnum() to verify that a value is a valid number, but these checks don't cover infinity.
Splunk example
| eval is_valid = if(isnum(value) AND value != 'Infinity', 1, 0)APL equivalent
['sample-http-logs']
| extend is_valid = isfinite(value)ANSI SQL users
Standard SQL does not define an ISFINITE() function. You typically check for IS NOT NULL and whether the value falls within a valid range, but you cannot directly detect infinity in most SQL dialects.
SQL example
SELECT CASE WHEN value IS NOT NULL AND value BETWEEN -1e308 AND 1e308 THEN 1 ELSE 0 END AS is_valid FROM logsAPL equivalent
['sample-http-logs']
| extend is_valid = isfinite(value)