Skip to content

Commit

Permalink
Resolve "Evolució mensual acumulada - Preu OMIE" (et/somenergia-jardi…
Browse files Browse the repository at this point in the history
…ner!130)

* hacky calendar year moving average of omie price
  • Loading branch information
polmonso committed Mar 4, 2024
1 parent c685515 commit 0828f0a
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,22 @@ with production_monthly_w_target as (
production_monthly.energia_esperada_solargis_mwh,
production_monthly.energia_perduda_mwh,
production_monthly.preu_omie_eur_mwh,
(
sum(production_monthly.preu_omie_eur_mwh)
over plant_year_window
) / extract(month from production_target.month)
as moving_avg_preu_omie_eur_mwh,
production_target.energy_production_target_mwh as energia_objectiu_mwh,
sum(production_monthly.energia_exportada_comptador_mwh)
over (partition by plant_uuid, extract(year from production_monthly.month) order by production_monthly.month)
over plant_year_window
as cumsum_energia_exportada_comptador_mwh,
sum(production_target.energy_production_target_mwh)
over (partition by plant_uuid, extract(year from production_target.month) order by production_target.month)
over plant_year_window
as cumsum_energia_objectiu_mwh
from {{ ref("int_gda_plants__plants_catalog") }} as plant_catalog
left join {{ ref("int_production_target__monthly") }} as production_target using (plant_uuid)
left join {{ ref("dm_plant_production_monthly") }} as production_monthly using (plant_uuid, month)
window plant_year_window as (partition by plant_uuid, extract(year from production_monthly.month) order by production_monthly.month)
order by production_target.month desc, plant_catalog.plant_name desc
)
select * from production_monthly_w_target

0 comments on commit 0828f0a

Please sign in to comment.