var()

Table of Contents

Definition

var() returns the sample variance in the table column. You can use it with the transform commands that support aggregations.

Examples

The following example returns the sample variance for prices in sales_inventory dataset. rex4j is used for extracting prices from the _raw column. eval creates a new table column that contains only the year of the timestamp which is used for grouping the result.

%dpl
index=sales_inventory earliest="01/01/2017:00:00:00"
| rex4j field=_raw "price=(?<price>\d+)"
| eval year=strftime(_time, "%Y")
| stats var(price) by year
example of var() aggregation command

Further Reading