Skip to main content
Use the floor function to round a numeric value down to the largest integer less than or equal to the input. This function is useful when you need to ensure that fractional values always round down, such as when calculating completed intervals, resource consumption, or discrete counts. Use floor when you want to convert decimal numbers to whole numbers by truncating the fractional part. For example, if a user has completed 2.7 sessions, floor returns 2 to represent fully completed sessions.

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 use the floor function to round down values. APL’s floor function works identically.
| eval completed_seconds = floor(duration_ms / 1000)
In ANSI SQL, the FLOOR function performs the same operation. APL’s syntax is nearly identical.
SELECT FLOOR(request_duration / 1000) AS completed_seconds FROM logs

Usage

Syntax

floor(number)

Parameters

NameTypeDescription
numberrealThe numeric value to round down.

Returns

An integer representing the largest whole number less than or equal to the input value.

Use case examples

Calculate completed seconds from millisecond durations.Query
['sample-http-logs']
| extend completed_ms = floor(req_duration_ms)
| summarize request_count = count() by completed_ms
| order by completed_ms asc
Run in PlaygroundOutput
completed_secondsrequest_count
08540
12310
2890
3245
This query converts request durations to whole milliseconds by rounding down, then groups requests by their completion time.
  • ceiling: Rounds up to the smallest integer greater than or equal to the input. Use floor when you need to round down instead.
  • bin: Rounds values down to a multiple of a specified bin size. Use floor for simple downward rounding to integers.
  • round: Rounds to the nearest integer or specified precision. Use floor when you always need to round down.