Hello,
With my energy supplier, I’m billed from the 17th to the 16th.
So I made this script and chart to adapt.
import "timezone"
import "date"
option location = timezone.location(name: "Europe/Paris")
from(bucket: "GIN")
|> range(start: 2024-03-17T00:00:00Z, stop: 2024-04-16T12:00:00Z)
|> filter(fn: (r) => r["_measurement"] == "ConsoElec")
|> cumulativeSum(columns: ["_value"])
|> map(fn: (r) => ({ r with dayOfMonth: uint(v: date.monthDay(t: r._time)) }))
|> fill(column: "dayOfMonth", usePrevious: true)
I’ve got several queries that interrogate predefined dates, and the day number is added in a column to create an XY graph.
With Flux, I try to create an average value for each day, but I don’t have enough time for each value.
So I can’t insert it into the XY to see more easily which curve is above or below the average.
import "timezone"
import "date"
option location = timezone.location(name: "Europe/Paris")
get_values = (start, stop) =>
from(bucket: "GIN")
|> range(start: start, stop: stop)
|> filter(fn: (r) => r["_measurement"] == "ConsoElec")
|> cumulativeSum(columns: ["_value"])
|> map(fn: (r) => ({ r with dayOfMonth: uint(v: date.monthDay(t: r._time)) }))
|> fill(column: "dayOfMonth", usePrevious: true)
valeur1 = get_values(start: 2024-05-16T18:00:00Z, stop: 2024-06-16T12:00:00Z)
valeur2 = get_values(start: 2024-04-16T18:00:00Z, stop: 2024-05-16T12:00:00Z)
combined = union(tables: [valeur1, valeur2])
daily_mean = combined
|> group(columns: ["dayOfMonth"])
|> mean(column: "_value")
|> yield(name: "daily_mean")
daily_mean
In addition to this, I’d like to create an indicator that establishes the difference between the current month’s cumulative total and the average cumulative total (comparable to today).
Thanks for your help