How do I Compare Time Ranges in OPAL?¶
There is not currently a specific mechanism to comparing a value versus that same value one day or week ago. Instead, this function can be achieved by using union with a second stage that offsets the time, bringing data samples from “yesterday” forward to “today”.
Example OPAL:
make_col series:"today"
@shifted <- @ {
// offset the time forward by 1 day to bring yesterday into today
make_col new_vf:timestamp+1d
// use the shifted time column
set_valid_from options(max_time_diff:25h), new_vf
rename_col timestamp:new_vf
// and mark this series as yesterday
make_col series:"yesterday"
}
union @shifted
// do whatever aggregation you're looking at, include the series indicator
timechart 1h, count(1), group_by(series)
The query time window must include both yesterday and today for this to work.