bin() / floor()
bin(value, size) rounds a value down to a multiple of size. With times, that means “the start of
the interval this time falls in”:
bin(datetime(2026-06-14 17:42:10), 1h) // 2026-06-14 17:00:00
bin(datetime(2026-06-14 17:42:10), 1d) // 2026-06-14 00:00:00
Its main use is inside summarize, to count or aggregate per time interval:
SigninLogs
| summarize Failures = countif(ResultType != "0") by bin(TimeGenerated, 1h)
The grouped column keeps the original name (TimeGenerated) unless you name it, for example
by Hour = bin(TimeGenerated, 1h).
bin() also works on numbers: bin(47, 10) is 40. That is handy for building ranges, for example
grouping users by how many sign-ins they had. floor() is another name for bin().
Things to know
- Intervals start at midnight UTC for day bins, and at the full hour for hour bins.
- Intervals with no events produce no row. A chart of the result skips them, so a gap in the data can
look like a straight line. (
make-series, which fills the gaps with zeros, is not supported on this site yet.) - Choosing the size matters. With
1dbins, two sign-ins from different countries 50 minutes apart look the same as two sign-ins 20 hours apart.
Examples
SigninLogs
| summarize SignIns = count() by Day = bin(TimeGenerated, 1d)
| sort by Day ascThe weekend (13 and 14 June) is easy to spot.
DeviceNetworkEvents
| where DeviceName == "ws-prg-011.kestrelbay.example"
| summarize Connections = count() by bin(TimeGenerated, 6h)
| sort by TimeGenerated ascBuckets with no events don't appear at all; there are no zero rows.
print Hour = bin(datetime(2026-06-14 17:42:10), 1h), Day = floor(datetime(2026-06-14 17:42:10), 1d), Tens = bin(47, 10)Practice it
+ 5 in the full SC-200 set · all exercises