Get values from last month (1th to 31th-isch) regardless of selected time range

I have a metric from influxDB that registers “current” power draw from my heating system, meaning I have 30s resolution on the currently active power level of the “extra” electrical heater on my heat pump.

This will always be a fixed value between 1-7 kW for each metric.

I can get the power consumption (in Wh) for the selected time period, by doing:

SELECT integral("eltillsats", 1h)*10 FROM "nibe" WHERE $timeFilter

(it’s multiplied by 10 because it is reported with the base of 10W).

I can also get the month to date consumption by adding now/M as Relative time under Query Options.

What I can’t seem to crack, is how to get the value for “last month”. If I add now-1M/M, I get last month to date, which is not what I want, and if I add Time shift 1M I seem to get the value of beginning of last month (e.g 1 jan) but up to current date minus 1 month (e.g 19th jan).

How can I do 1th to 31th of january, when I’m in February? do I need a fixed time range, but how do I get last of first month, and first of month in the query?

I managed to figure it out. Using:

now-1M/M as relative time, and time shift set to 1M/M seem to do the trick.

1 Like

Can you please show the full query?