Skip to main content

Window Functions

In addition to standard metrics, it is possible to define running window calculations of your data whether you are looking to monitor a cumulative trend, smooth out fluctuations, etc. You'll need to navigate to the Code view in order to create a windowed measure.

Please review the reference documentation, here.

Example

In the below example, bids is another measure defined in the metrics view, and we are getting the previous week and current date's values and averaging them. This allows us to remove any short term trends to detect real patterns. You'll need to add the requires array parameter to use reference another measure.


update this photo

  - name: bids_7day_rolling_avg
display_name: 7 Day Bid rolling avg
expression: AVG(total_bids)
requires: [total_bids]
window:
order: "__time"
frame: RANGE BETWEEN INTERVAL 6 DAY PRECEDING AND CURRENT ROW

Another example is using a rolling sum with no bounding preceding rows, aka your whole data. This will be a cumulative sum of all of your measure's data, in this case it is the average voltage measure.


  - name: rolling_sum_avg_voltage_all_time
display_name: Rolling Sum Windowed Voltage Average
expression: SUM(average_voltage_measure)
requires: [average_voltage_measure]
window:
order: Date
frame: RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW

Demo

See this project live in our demo!