Beta — Data under validation. Values may contain errors.

ED.RANGE

Generic time-series access for any of 120+ metrics — average value or total energy.

Generic + metrics

Signature

ED.RANGE(metric, [start], [end], [agg], [zone], [headers], [noDate], [method], [tz], [unit])

Description

Generic time-series accessor for any metric in the catalog. Output is a spill array with auto-formatted period and value columns. Use ED.METRICS() to discover available metrics.

Aggregation is controlled by agg: 0=native, 5min/10min/15min, 1=hourly, 2=daily (default), 3=monthly, 4=quarterly, 5=semiannual, 6=annual, 7=total.

**Unit (unit parameter):** by default each bucket holds the AVERAGE of the stored values. For metrics whose stored unit is MW (generation, demand, balancing band capacity, cross-border flows) you can pass unit="MWh" to convert to total energy delivered in each bucket — multiplied by the metric's native sample interval (5 min for ESIOS Spain gen/demand, 15 min for balancing, 60 min for ENTSO-E). Calling it on a price (EUR/MWh) or already-MWh metric returns a 400 error.

Pass tz to switch the timezone interpretation: 0/madrid (default, DST-aware), 1/cet (UTC+1 fixed — 8760 hourly buckets/year), or 2/utc. See /docs/concepts for why this matters around the spring/autumn DST transitions. The method argument is a no-op for everything except capture_* metrics, where 0=realized and 1=PBF.

Parameters

NameTypeDefaultDescription
metric*stringMetric name (see ED.METRICS).
startdateStart. Defaults: omit end for today (Madrid, with a small overnight cutoff), omit start for 30 days before end.
enddateEnd. Omit for today.
agg0-7 | string2 (daily)Aggregation is controlled by agg: 0=native, 5min/10min/15min, 1=hourly, 2=daily (default), 3=monthly, 4=quarterly, 5=semiannual, 6=annual, 7=total.
zone"ES" | "PT""ES"Zone (electricity metrics only).
headers0 | 10Set 1 for header row.
noDate0 | 10Set 1 to omit the period column.
method0 | 10capture_* metrics: 0=realized, 1=PBF. Ignored for other metrics.
tz0 | 1 | 2"madrid"Timezone interpretation.
unit"MW" | "MWh""MW"For MW-stored metrics: "MW" returns AVG (default). "MWh" converts to total energy via SUM × native_sample_minutes/60.

* Required.

Returns

Spill array — [period, value] rows with format inferred from the metric's unit (or MWh if unit="MWh").

Examples

=ED.RANGE("eua_co2", "2020-01-01",, 3)CO2 monthly since 2020
=ED.RANGE("dayahead", "2025-01-01", "2025-12-31", 1, "PT", 1)PT hourly day-ahead with headers
=ED.RANGE("demand_real", "2025-07-01", "2025-07-01", 0)Real demand 5-min for one day (MW)
=ED.RANGE("demand_real", "2025-01-01",, 6, , , , , , "MWh")Real demand annual energy (MWh) — total electricity consumed
=ED.RANGE("gen_total", "2025-01-01", "2025-12-31", 6, , , , , , "MWh")Total domestic generation 2025 (MWh) — virtual aggregate, T.Real real-time
=ED.RANGE("gen_total_measured", "2025-01-01", "2025-12-31", 6)Same total but from REE\'s official measured series (settled, MWh)
=ED.RANGE("gen_renewable", "2025-01-01", "2025-12-31", 3, , , , , , "MWh")Renewable generation monthly (MWh) — solar+wind+hydro+biomass+…
=ED.RANGE("gen_fossil", "2025-01-01", "2025-12-31", 6, , , , , , "MWh")Fossil-fuel generation 2025 — for emissions analysis
=ED.RANGE("afrr_energy_up", "2025-01-01",, 3)aFRR upward energy activated, monthly. Already MWh-stored — SUM aggregation auto-applied.
=ED.RANGE("brent", "2010-01-01",, 6)Brent annual since 2010

Notes

  • Virtual gen aggregates (gen_total, gen_renewable, gen_thermal, gen_fossil) are computed on-the-fly: per civil hour the API averages the constituent gen_* metrics, then sums those over your bucket. They behave like any other MW metric — both unit=MW (default) and unit=MWh work.
  • gen_total constituents (ES peninsular): solar_pv, solar_thermal, wind, nuclear, hydro, combined_cycle, coal, cogeneration, biomass, fuel_gas, pumped_storage, plus ENTSO-E catch-alls (oil, geothermal, other_renewable, waste, other) for non-Iberian zones. With this set the totals match REE published peninsular generation within ~1-2%.
  • gen_total excludes gen_exchanges (interconnections, not domestic production) and gen_pumped_consumption (charging load, not generated energy). To include imports add gen_exchanges manually: =ED.RANGE("gen_total", …) + ED.RANGE("gen_exchanges", …).
  • gen_thermal includes nuclear + cogeneration; gen_fossil excludes nuclear. Use gen_fossil for emissions analysis.
  • **Authoritative alternative — gen_total_measured**: REE's official post-settlement total (ESIOS id 10043, sum of per-province measured generation). Hourly, ~2-3 day lag, already in MWh. Use this when your output needs to match REE's published reports to the decimal. The virtual gen_total is the same concept built from real-time T.Real indicators — slightly different numbers (1-2%) but available with no settlement lag.
  • **Auto-SUM for MWh-stored metrics**: when a metric is already stored as energy (MWh) — e.g. gen_total_measured, intraday_s*_energy, afrr_energy_up/down, mfrr_*_assign_* — bucket aggregation uses SUM instead of AVG. Asking for unit="MWh" on these is a no-op (already energy). Asking for unit="MW" is silently ignored (energy can't be converted back to power without knowing the time span).

Related functions