range 运算符range operator

生成值的单列表。Generates a single-column table of values.

请注意,该表不含管道输入。Notice that it doesn't have a pipeline input.


range columnName from start to stop step steprange columnName from start to stop step step


  • columnName:输出表中的单列名称。columnName: The name of the single column in the output table.
  • start:输出中的最小值。start: The smallest value in the output.
  • stop:输出中正生成的最大值(如果 step 跳过此值,则为最大值边界)。stop: The highest value being generated in the output (or a bound on the highest value, if step steps over this value).
  • step:两个连续值之间的差异。step: The difference between two consecutive values.

参数必须为数字、日期或时间跨度值。The arguments must be numeric, date or timespan values. 它们不能引用任何表的列。They can't reference the columns of any table. (如需基于输入表计算范围,请使用 range 函数,可能需配合使用 mv-expand 运算符。)(If you want to compute the range based on an input table, use the range function, maybe with the mv-expand operator.)


一个包含单个列 columnName 的表,其值包括 start、start + step...,直至 stop 。A table with a single column called columnName, whose values are start, start + step, ... up to and until stop.


过去 7 天午夜时分的表。A table of midnight at the past seven days. bin (floor) 函数将每次时间缩减到当天的开始。The bin (floor) function reduces each time to the start of the day.

range LastWeek from ago(7d) to now() step 1d
2015-12-05 09:10:04.6272015-12-05 09:10:04.627
2015-12-06 09:10:04.6272015-12-06 09:10:04.627
2015-12-12 09:10:04.6272015-12-12 09:10:04.627

一个包含单个列 Steps 的表,其类型是 long,其值是 147A table with a single column called Steps whose type is long and whose values are 1, 4, and 7.

range Steps from 1 to 8 step 3

下一个示例演示如何使用 range 运算符创建小型的临时维度表,并使用该表在源数据不具有值的位置引入零。The next example shows how the range operator can be used to create a small, ad-hoc, dimension table which is then used to introduce zeros where the source data has no values.

range TIMESTAMP from ago(4h) to now() step 1m
| join kind=fullouter
      | where TIMESTAMP > ago(4h)
      | summarize Count=count() by bin(TIMESTAMP, 1m)
| project Count=iff(isnull(Count), 0, Count), TIMESTAMP
| render timechart