# PERDEMAND

> PERDEMAND sets out the regional demands and MR schedule data for each half-hour period. PERDEMAND is a child table to [`RESDEMANDTRK`](./RESDEMANDTRK.md).

> The [`RESDEMANDTRK`](./RESDEMANDTRK.md) and PERDEMAND tables have a parent/child relationship,
> and define forecast regional demands since market start. [`RESDEMANDTRK`](./RESDEMANDTRK.md)
> defines the existence and versioning information of a forecast for a
> specific region and trading date. PERDEMAND defines the numerical
> forecast values for each trading interval of a the trading day for that
> region. A complete trading day forecast for one region consists of one
> [`RESDEMANDTRK`](./RESDEMANDTRK.md) record and 48 PERDEMAND records.
> 
> Source
> 
> PERDEMAND updates whenever AEMO issues a new or revised forecast. ST
> PASA forecasts update seven days at a time. Predispatch updates one
> date.
> 
> Volume
> 
> 1296000 rows per year
> 
> Note
> 
> In the context of a mandatory restrictions event the forecast schedule
> (MW) of restrictions are reported through the [`RESDEMANDTRK`](./RESDEMANDTRK.md) and PERDEMAND
> tables using the new field PerDemand.MR_Schedule. The relationship
> between fields and mandatory restriction terms for the 50% probability
> of exceedence forecast are:
> 
> · UnRestricted Profile = ResDemand + MR_Schedule
> 
> · Restricted Profile = ResDemand

## Column Schema

### OFFERDATE

> Date record issued

SQL Type: `DATE`
Polars Type: `pl.Date()`

This column is mandatory, and a primary key.

Example: `2026/08/25 00:00:00`

Note that AEMO represents dates as datetimes with a midnight time component.

### PERIODID

> Half hourly trading intervals from 04:30.

SQL Type: `NUMBER(3,0)`
Polars Type: `pl.Int16`

This column is mandatory, and a primary key.

Examples:
`1`, `48`

### REGIONID

> Differentiates this region from all other regions

For more information, see the [dedicated documentation page](../../guide/querying.md#region-id).

The SQL type is `VARCHAR2(10)`.
This is actually a factor/enum, with values:

- `QLD1`

- `VIC1`

- `TAS1`

- `NSW1`

- `SA1`

- `SNOWY1`

This column is mandatory, and a primary key.

### SETTLEMENTDATE

> Market date of forecast up to 7 days ahead.

SQL Type: `DATE`
Polars Type: `pl.Date()`

This column is mandatory, and a primary key.

Example: `2026/09/01 00:00:00`

Note that AEMO represents dates as datetimes with a midnight time component.

### VERSIONNO

> The version of the RESDEMAND file for this date

SQL Type: `NUMBER(3,0)`
Polars Type: `pl.UInt16`

This column is mandatory, and a primary key.

Examples:
`2`, `48`

### DEMAND10PROBABILITY

> Demand level for a 10% probability of exceedance

SQL Type: `NUMBER(10,0)`
Polars Type: `pl.Int64`

This column is not mandatory.

Examples:
`4553`, `9671`

### DEMAND90PROBABILITY

> Demand at 90% probability of exceedance

SQL Type: `NUMBER(10,0)`
Polars Type: `pl.Int64`

This column is not mandatory.

Examples:
`4128`, `8762`

### EFFECTIVEDATE

> Market date the forecast is made for. First date of the 7 days.

SQL Type: `DATE`
Polars Type: `pl.Date()`

This column is not mandatory.

Example: `2026/09/01 00:00:00`

Note that AEMO represents dates as datetimes with a midnight time component.

### LASTCHANGED

> Last date and time record changed

For more information, see the [dedicated documentation page](../../guide/querying.md#deduplication).

SQL Type: `DATE`
Polars Type: `pl.Datetime()`

This column is not mandatory.

Example: `2026/08/25 12:57:10`

### MR_SCHEDULE

> MR_Schedule = Unrestricted Demand - POE

SQL Type: `NUMBER(6,0)`
Polars Type: `pl.Int32`

This column is not mandatory.

Example: `0`

### RESDEMAND

> Base Demand forecast for period

SQL Type: `NUMBER(10,0)`
Polars Type: `pl.Int64`

This column is not mandatory.

Examples:
`4340`, `9217`

## New Data Timing

> When AEMO issues a new or revised forecast. ST PASA forecasts update seven days at a time. Predispatch updates one date.

## Code Examples

### Polars

Explicitly listing every column, casting to enums, categoricals etc is not essential, but may speed up parsing.
Swapping `int` for `pl.UInt16`, `pl.Int32` would also speed up parsing. However some of the datatypes are inferred, so they may be wrong.

This code deduplicates for you.
Deduplication is normally only required across multiple months.

This code assumes that all columns are present, which may not be true for older files.

```python
import polars as pl
import polars.selectors as cs

# e.g. "2029/03/15 00:05:00"
dt_s_fmt = "%Y/%m/%d %H:%M:%S"

# Dates are represented as datetimes at midnight

d_fmt = "%Y/%m/%d 00:00:00"

csv_paths = ["SOMEFILE.CSV", "OTHERFILE.CSV"]

lf = (
    pl.concat(
        [
            pl.scan_csv(
                csv_path,  # must be unzipped beforehand
                skip_rows=1,  # skip the header
                infer_schema=False,  # much faster
            )
            .filter(cs.by_index(0) == "D")  # drop the footer
            .select(~cs.by_index(range(4)))  # drop metadata columns
            for csv_path in csv_paths
        ],
        how="diagonal_relaxed",
    )
    .with_columns(
        pl.col("LASTCHANGED").str.strptime(pl.Datetime, dt_s_fmt),
        pl.col("OFFERDATE", "SETTLEMENTDATE", "EFFECTIVEDATE").str.strptime(
            pl.Date, d_fmt
        ),
    )
    .cast(
        {
            "OFFERDATE": pl.Date(),
            "PERIODID": int,  # or pl.Int16
            "REGIONID": pl.Enum(["QLD1", "VIC1", "TAS1", "NSW1", "SA1", "SNOWY1"]),
            "SETTLEMENTDATE": pl.Date(),
            "VERSIONNO": int,  # or pl.UInt16
            "DEMAND10PROBABILITY": int,  # or pl.Int64
            "DEMAND90PROBABILITY": int,  # or pl.Int64
            "EFFECTIVEDATE": pl.Date(),
            "MR_SCHEDULE": int,  # or pl.Int32
            "RESDEMAND": int,  # or pl.Int64
        }
    )
    # Deduplicate
    # We want one row per ['OFFERDATE', 'PERIODID', 'REGIONID', 'SETTLEMENTDATE', 'VERSIONNO']
    # Tie-breaker: greatest value of ['LASTCHANGED']
    .sort(["LASTCHANGED"], descending=False)
    .unique(
        subset=["OFFERDATE", "PERIODID", "REGIONID", "SETTLEMENTDATE", "VERSIONNO"],
        keep="last",
    )
)

```

### Nemosis

This table is not yet available in [Nemosis](https://github.com/UNSW-CEEM/NEMOSIS/#static_table).

## Example File

From [PUBLIC_ARCHIVE_PERDEMAND_FILE01_202609010000.zip](https://www.nemweb.com.au/Data_Archive/Wholesale_Electricity/MMSDM/2026/MMSDM_2026_09/MMSDM_Historical_Data_SQLLoader/DATA/PUBLIC_ARCHIVE%23PERDEMAND%23FILE01%23202609010000.zip)

=== "Raw Text with Metadata"
    ```csv
    C,SETP.WORLD,DVD_PERDEMAND,AEMO,PUBLIC,2026/10/09,16:26:13,001791527173905,MONTHLY_ARCHIVE,001791527173905
    I,DEMAND,PERIOD,1,EFFECTIVEDATE,SETTLEMENTDATE,REGIONID,OFFERDATE,PERIODID,VERSIONNO,RESDEMAND,DEMAND90PROBABILITY,DEMAND10PROBABILITY,LASTCHANGED,MR_SCHEDULE
    D,DEMAND,PERIOD,1,"2026/09/01 00:00:00","2026/09/01 00:00:00",NSW1,"2026/08/25 00:00:00",1,26,6822,6493,7151,"2026/08/25 12:57:10",0
    D,DEMAND,PERIOD,1,"2026/09/01 00:00:00","2026/09/01 00:00:00",NSW1,"2026/08/25 00:00:00",2,26,6918,6584,7252,"2026/08/25 12:57:10",0
    D,DEMAND,PERIOD,1,"2026/09/01 00:00:00","2026/09/01 00:00:00",NSW1,"2026/08/25 00:00:00",3,26,7178,6831,7526,"2026/08/25 12:57:10",0
    D,DEMAND,PERIOD,1,"2026/09/01 00:00:00","2026/09/01 00:00:00",NSW1,"2026/08/25 00:00:00",4,26,7475,7112,7838,"2026/08/25 12:57:10",0
    D,DEMAND,PERIOD,1,"2026/09/01 00:00:00","2026/09/01 00:00:00",NSW1,"2026/08/25 00:00:00",5,26,7925,7539,8310,"2026/08/25 12:57:10",0
    D,DEMAND,PERIOD,1,"2026/09/01 00:00:00","2026/09/01 00:00:00",NSW1,"2026/08/25 00:00:00",6,26,8236,7835,8638,"2026/08/25 12:57:10",0
    D,DEMAND,PERIOD,1,"2026/09/01 00:00:00","2026/09/01 00:00:00",NSW1,"2026/08/25 00:00:00",7,26,8193,7793,8593,"2026/08/25 12:57:10",0
    D,DEMAND,PERIOD,1,"2026/09/01 00:00:00","2026/09/01 00:00:00",NSW1,"2026/08/25 00:00:00",8,26,7820,7438,8203,"2026/08/25 12:57:10",0
    D,DEMAND,PERIOD,1,"2026/09/01 00:00:00","2026/09/01 00:00:00",NSW1,"2026/08/25 00:00:00",9,26,7225,6871,7580,"2026/08/25 12:57:10",0
    D,DEMAND,PERIOD,1,"2026/09/01 00:00:00","2026/09/01 00:00:00",NSW1,"2026/08/25 00:00:00",10,26,6527,6206,6848,"2026/08/25 12:57:10",0
    D,DEMAND,PERIOD,1,"2026/09/01 00:00:00","2026/09/01 00:00:00",NSW1,"2026/08/25 00:00:00",11,26,5978,5683,6272,"2026/08/25 12:57:10",0
    ...
    C,"END OF REPORT",1003
    ```

## Availability

Visibility: Public

This table is in the public monthly [MMSDM archive](https://www.nemweb.com.au/Data_Archive/Wholesale_Electricity/MMSDM/).

I have collated the list of all those files into one place, in [this CSV metadata file](../../manifests/per_table/csv/PERDEMAND.csv). (Columns `year`, `month`, `url`, `compressed_size` in bytes).

The earliest available data is month 1 of 2015.
The most recent available data is month 9 of 2026.

 Every month in between has a file. (No gaps.)

## Data Size

Each year of data is approximately
205 MB when zipped,
2 GB as unzipped CSV.

## Deduplication and PDR Loader Configuration

The primary keys are:

- [`OFFERDATE`](#offerdate)

- [`PERIODID`](#periodid)

- [`REGIONID`](#regionid)

- [`SETTLEMENTDATE`](#settlementdate)

- [`VERSIONNO`](#versionno)

The transaction type is ["insert"](https://di-help.docs.public.aemo.com.au/Content/pdrLoader/How_it_works.htm?TocPath=pdrLoader%7CAbout+pdrLoader%7C_____5#INSERT), which means that you will usually not see duplicate data.
If you do, you can deduplicate based on the primary keys, without sorting first.
Rows from different files with the same primary keys should have the same values.

[PDR Loader configuration](https://nemweb.com.au/Reports/Current/MMSDataModelReport/PDRCONFIG/PROD_PUBLIC_PDR_CONFIG_FULL.zip) is:

| Report Name | Report Subtype | Version |
|---------------|-------------------|-----------|
| DEMAND | PERIOD  | 1 |

This means that the CSV files start with metadata columns:

```csv
I,DEMAND,PERIOD,1,...
D,DEMAND,PERIOD,1,...
```

## Indexes

- [`LASTCHANGED`](#lastchanged)

## Links

[This page as JSON](../json/tables/PERDEMAND/bespoke.json) (schema documented [here](https://gitlab.com/MatthewDavis/mms-schema/-/blob/master/schema.py?ref_type=heads), but may change)

Download a [JSON Schema](../json/tables/PERDEMAND/json-schema.json) specification for this table.

[Official AEMO schema documentation](https://nemweb.com.au/Reports/Current/MMSDataModelReport/Electricity/ElectricityDataModelReport_files/Elec18.htm#121)

## Other Information

Package: [DEMAND_FORECASTS](../packages/DEMAND_FORECASTS.md)
