# Explore 40 years of Austrian lottery draws with dcupl

Every draw of the Austrian Lotto "6 aus 45" since September 1986 and every EuroMillionen draw since 2004, with the drawn numbers, the number of winners and the prize per winner in each tier. This example is a ready-made dcupl workspace: clone it, load it with one command, and query 40 years of draws from your terminal.

**Time required:** 5 minutes

**What you will learn:** read dates in a custom format, build labels with expression properties, split one model over many files, and query across several columns with an OR group.

## The dataset

The draws come from the official result downloads of the Austrian Lotteries on [win2day](https://www.win2day.at/lotterie/lotto/lotto-statistik-zahlen-ergebnisse-download). The demo workspace on [GitHub](https://github.com/dcupl-demos/lotto-euromillionen-austria) cleans them up for loading: one column layout per game, decimal points instead of decimal commas, and the known errors of the source files fixed (a duplicate draw, a mistyped year, swapped columns, numbers copied from an earlier draw).

| Model           | Draws | Period       | Files                                                          |
| --------------- | ----: | ------------ | -------------------------------------------------------------- |
| `lotto`         | 3,684 | 1986 to 2026 | 12 CSV files, one per period or year (`lotto-ziehungen-*.csv`) |
| `euromillionen` | 1,981 | 2004 to 2026 | 11 CSV files (`euromillionen-*.csv`)                           |

Lotto prize rates are in Austrian schilling (ATS) until 2000 and in euro since 2001; the `currency` column says which. The numbers below are from the workspace at the time of writing; new draws change them.

## Prerequisites

- The [dcupl CLI](/cli/installation) installed (`dcupl --version` to check)
- Git

## Step 1: get the workspace

```bash filename="terminal"
git clone https://github.com/dcupl-demos/lotto-euromillionen-austria.git austrian-lottery
cd austrian-lottery
```

The workspace has the usual layout: the models in `dcupl/models/`, the CSV files in `dcupl/data/` and the loader configuration in `dcupl/dcupl.lc.json`.

## Step 2: read the model

`dcupl/models/lotto.dcupl.json` describes one draw. A few properties show features worth knowing:

```json title="lotto.dcupl.json (excerpt)"
{
  "key": "lotto",
  "autoGenerateKey": true,
  "properties": [
    { "key": "date", "type": "date", "inputFormat": "dd.MM.yyyy", "UTC": true },
    { "key": "currency", "type": "string" },
    {
      "key": "numbersAsc",
      "type": "string",
      "expression": "${nr1asc}, ${nr2asc}, ${nr3asc}, ${nr4asc}, ${nr5asc}, ${nr6asc}"
    },
    {
      "key": "numbersAscWithAdditional",
      "type": "string",
      "expression": "${nr1asc}, ${nr2asc}, ${nr3asc}, ${nr4asc}, ${nr5asc}, ${nr6asc} + ${additionalNr}"
    },
    { "key": "nr1asc", "type": "int" },
    { "key": "sixWinners", "type": "int" },
    { "key": "rateSix", "type": "float" }
  ]
}
```

- **`inputFormat`** reads the Austrian date format of the files (`20.09.2026`); `UTC: true` keeps the date on the day it was drawn, whatever the time zone of the machine.
- **Expressions** join the six numbers (stored sorted in `nr1asc` to `nr6asc`) into one label, `3, 4, 15, 31, 32, 41`. A label is a value like any other, so you can facet and filter on it.
- **`autoGenerateKey`**: a draw has no ID column, so dcupl generates the keys.

The loader configuration lists the 12 Lotto files as data resources of the same model, so one model collects all of them. It also defines loader applications (`lotto`, `lotto-ATS`, `lotto-EUR`, `euromillionen`) that load only the files with certain tags, for example only the euro years; see [Applications](/sdk/api/loader#applications).

## Step 3: load the data

```bash filename="terminal"
dcupl app create --load --auto-serve
```

All 23 files load into the two models in a few seconds.

## Step 4: query the draws

### The latest draws

```bash filename="terminal"
dcupl app query execute --model lotto --sort date:desc --limit 3 \
  --projection date,weekday,numbersAscWithAdditional,sixWinners,rateSix --json
```

```json title="Output"
[
  {
    "date": "2026-09-20T00:00:00.000Z",
    "weekday": "Sunday",
    "numbersAscWithAdditional": "3, 4, 15, 31, 32, 41 + 10",
    "sixWinners": 0,
    "rateSix": 1242576.5
  },
  {
    "date": "2026-09-18T00:00:00.000Z",
    "weekday": "Friday",
    "numbersAscWithAdditional": "5, 6, 12, 35, 38, 39 + 8",
    "sixWinners": 0,
    "rateSix": 579034.3
  },
  {
    "date": "2026-09-16T00:00:00.000Z",
    "weekday": "Wednesday",
    "numbersAscWithAdditional": "1, 6, 7, 13, 33, 38 + 43",
    "sixWinners": 1,
    "rateSix": 1200000
  }
]
```

### Schilling and euro draws

```bash filename="terminal"
dcupl app fn facets --model lotto --attribute currency --json
```

```json title="Output"
[
  { "value": "ATS", "count": 919 },
  { "value": "EUR", "count": 2765 }
]
```

Compare prize rates only within one currency. The highest first prizes since the euro, each won by a single ticket:

```bash filename="terminal"
dcupl app query execute --model lotto \
  --query '{"attribute":"currency","operator":"eq","value":"EUR"}' \
  --sort rateSix:desc --limit 3 --projection date,numbersAsc,sixWinners,rateSix --json
```

```json title="Output"
[
  {
    "date": "2018-11-21T00:00:00.000Z",
    "numbersAsc": "20, 25, 29, 32, 37, 44",
    "sixWinners": 1,
    "rateSix": 14926157.3
  },
  { "date": "2026-07-19T00:00:00.000Z", "numbersAsc": "1, 10, 15, 21, 29, 42", "sixWinners": 1, "rateSix": 12050822.5 },
  { "date": "2024-09-22T00:00:00.000Z", "numbersAsc": "15, 19, 32, 37, 39, 40", "sixWinners": 1, "rateSix": 11152282.9 }
]
```

### Has a combination ever been drawn twice?

A facet on the `numbersAsc` expression counts how often each combination was drawn. Sorted by count, the top answers the question:

```bash filename="terminal"
dcupl app fn facets --model lotto --attribute numbersAsc --sort size-desc --limit 2 --json
```

```json title="Output"
[
  { "value": "12, 30, 32, 34, 37, 43", "count": 2 },
  { "value": ", , , , , ", "count": 1 }
]
```

Yes, one combination came up twice. The second entry is a draw without numbers: the source file gave the draw of 3 January 1995 the numbers of 3 January 1993, in the same drawn order and with the same additional number, which doesn't happen by chance. The workspace keeps that draw's date, winners and prize rates and drops its numbers, so its label renders empty. The README of the workspace lists every correction of this kind. When the combination came up:

```bash filename="terminal"
dcupl app query execute --model lotto \
  --query '{"attribute":"numbersAsc","operator":"eq","value":"12, 30, 32, 34, 37, 43"}' \
  --projection date,weekday,numbersAscWithAdditional,sixWinners --json
```

```json title="Output"
[
  {
    "key": "76kqqOQJdY",
    "date": "2014-01-22T00:00:00.000Z",
    "weekday": "Wednesday",
    "numbersAscWithAdditional": "12, 30, 32, 34, 37, 43 + 8",
    "sixWinners": 2
  },
  {
    "key": "24waffv7zS",
    "date": "2024-07-24T00:00:00.000Z",
    "weekday": "Wednesday",
    "numbersAscWithAdditional": "12, 30, 32, 34, 37, 43 + 21",
    "sixWinners": 0
  }
]
```

The same six numbers ten years apart, with different additional numbers: two winners shared the first prize in 2014, nobody won it in 2024. The keys are generated when the data loads, so yours differ.

### Draws with a given number

A number can sit in any of the six columns. An OR group matches a draw when any of its conditions does, and `fn metadata` returns the size of the result:

```bash filename="terminal"
dcupl app fn metadata --model lotto --json --query '{"groupType":"or","queries":[
  {"attribute":"nr1asc","operator":"eq","value":7},{"attribute":"nr2asc","operator":"eq","value":7},
  {"attribute":"nr3asc","operator":"eq","value":7},{"attribute":"nr4asc","operator":"eq","value":7},
  {"attribute":"nr5asc","operator":"eq","value":7},{"attribute":"nr6asc","operator":"eq","value":7}]}' \
  | jq '.currentSize'
```

```text title="Output"
517
```

The 7 came up in 517 of 3,684 draws, about one in seven; six numbers out of 45 is one in 7.5 on average.

### Prize rates of the smallest tier

The lowest, highest and average prize for three correct numbers in euro:

```bash filename="terminal"
dcupl app fn aggregate --model lotto --attribute rateThree --types min,max,avg \
  --query '{"attribute":"currency","operator":"eq","value":"EUR"}' --json
```

```json title="Output"
{ "attribute": "rateThree", "types": ["min", "max", "avg"], "min": 2.69, "max": 7.1, "avg": 4.746878842676305 }
```

The `euromillionen` model works the same way, with the five numbers and two stars and the winners in Europe and in Austria per tier (`winnersEU_5_2`, `winnersAT_5_2`, `rate_5_2`, …). When you are done, stop the app with `dcupl app destroy`.

## Use it in your application

The workspace is a regular dcupl project: the [loader](/sdk/api/loader) loads it in the browser or in Node.js, where one of its applications loads only the files you need (`lotto-EUR` for the euro years). At about 5,700 draws, the whole dataset is small enough for the browser.

## Next steps

- [Transfermarkt example](/learn/examples/transfermarkt) — generate models from CSV and link them
- [Expression properties](/sdk/advanced/expression-properties) — labels from several properties
- [Query operators](/sdk/api/query-operators) — every operator and query groups
- [Local data apps](/cli/local-data-apps) — every `dcupl app` command
