Hello,
I get a table “_RESULT” with a final Union step, all is working well.
I got the result by day (based on my calculation needed by day).
I would like to sum by month all my 3 “Total” Columns.
I really do not know how to do it.
Thanks in advance for your support
Union Table result
Just for you information, step of the union (all works well)
// Cout Tarif Jour
COST_Heure = from(bucket: "Jeedom")
|> range(start: -100y)
|> filter(fn: (r) => r["_measurement"] == "Cout_Heure_Creuse" or r["_measurement"] == "Cout_Heure_Pleine" or r["_measurement"] == "Cout_Abonnement")
|> filter(fn: (r) => r["_field"] == "Prix_kw")
|> pivot(rowKey:["_time"], columnKey: ["_measurement"], valueColumn: "_value")
|> keep(columns: ["_time","Cout_Heure_Creuse","Cout_Heure_Pleine"])
// |> keep(columns: ["_time","Cout_Heure_Creuse","Cout_Heure_Pleine","Cout_Abonnement"])
|> truncateTimeColumn(unit: 1d)
// Conso par Jour
CONSO = from(bucket: "Jeedom")
|> range(start: -100y)
|> filter(fn: (r) => r["_measurement"] == "STAT_TODAY" or r["_measurement"] == "STAT_TODAY_HC" or r["_measurement"] == "STAT_TODAY_HP")
|> filter(fn: (r) => r["_field"] == "Compteur")
|> aggregateWindow(every: 1d, fn: max, createEmpty: false)
|> pivot(rowKey:["_time"], columnKey: ["_measurement"], valueColumn: "_value")
|> keep(columns: ["_time","STAT_TODAY","STAT_TODAY_HC","STAT_TODAY_HP"])
// On va décaller d'une seconde en arrière pour retrouver la journée de consommation sinon attribué à la journée suivante car 00:00
|> timeShift(duration: -1s, columns: ["_time"])
|> truncateTimeColumn(unit: 1d)
//Merge des 2 tables
union(tables: [COST_Heure, CONSO])