NRQL: get value diff between two time points

Good day New Relic community!

I’m trying to build a chart (and probably an alert) to track the difference between infra daily costs this moth and the previous month.

From the visualisation point of view one can use COMPARE WITH clause to compare two charts visually.
But to build an alert we need to get the actual diff between current value an the value a month (week, day, etc.) ago.

Is it possible to do it with NRQL?

Might make more sense to alert off targets rather than some relative number from the past. Wont you have weird issues over time?

You can use some of the date functions and filters to achieve some specific compares and use math.

filter(count(*), where monthOf(timestamp) = ‘September 2020’)…