Contribute in GitHub:
Edit online
bin_at()
Rounds values down to a fixedsize bin, with control over the bin's starting point.
Syntax
bin_at
(
value,
bin_size,
fixed_point)
Parameters
Name  Type  Required  Description 

value  int, long, real, timespan, or datetime  ✓  The value to round. 
bin_size  int, long, real, or timespan  ✓  The size of each bin. 
fixed_point  int, long, real, timespan, or datetime  ✓  A constant of the same type as value indicating one value of value, which is a fixed point for which bin_at(fixed_point, bin_size, fixed_point) == fixed_point . 
If value is a timespan or datetime, then the bin_size must be a timespan.
Returns
The nearest multiple of bin_size below value, shifted so that fixed_point will be translated into itself.
Examples
Expression  Result  Comments 

bin_at(6.5, 2.5, 7) 
4.5 

bin_at(time(1h), 1d, 12h) 
12h 

bin_at(datetime(20170515 10:20:00.0), 1d, datetime(19700101 12:00:00.0)) 
datetime(20170514 12:00:00.0) 
All bins will be at noon 
bin_at(datetime(20170517 10:20:00.0), 7d, datetime(20170604 00:00:00.0)) 
datetime(20170514 00:00:00.0) 
All bins will be on Sundays 
In the following example, notice that the "fixed point"
arg is returned as one of the bins and the other bins are aligned to it based on the bin_size
. Also note that each datetime bin represents the starting
time of that bin:
events
 project original_time
 where original_time > ago(30d)
// USER Criteria He
 summarize Hits=count() by bin_at(datetime(20230615 10:20:00.0), 1d, datetime(19700101 12:00:00.0))
Results
Column  Hits 

20230614T12:00:00.000Z  209615 