# 101. Retail performance with Power BI

**Decision question:** How can a commercial team monitor sales, credits, and customer coverage without ambiguous KPI definitions?

This is an advanced BI extension of an existing portfolio study. It adds a reproducible analytical data mart, an editable native Power BI project, explicit KPI definitions and a review workflow.

## Result

The reconciled model preserves 541,909 source lines and £10.67 million of gross sales. Credits are 8.41% of gross invoiced value; identified customers cover 83.5% of gross sales.

The model makes grain, signed credits, distinct invoices, customer coverage, and filter context explicit. This is a BI implementation over existing source data, not an independent replication.

![Computed analysis chart](outputs/chart.png)

This figure is generated with Python from the same prepared results. It is an analytical chart, **not a screenshot of Power BI**.

## Power BI report

1. **Retail performance** — 9 report visuals, including interactive slicers and data-bound charts.
2. **Customer lens** — 9 report visuals, including interactive slicers and data-bound charts.
3. **Data quality & reconciliation** — 9 report visuals, including interactive slicers and data-bound charts.

The project contains 17 DAX measures and 4 active single-direction relationships. [Open the native project](powerbi/RetailPerformance.pbip), review the [data model](DATA_MODEL.md), and inspect the [measure definitions](MEASURES.md).

**Validation status:** Python analysis executed; report schemas and field references checked. Power BI Desktop is not installed in the authoring environment, so native refresh, DAX execution and page rendering are **not yet verified**. The files are PBIP/PBIR source projects, not compiled PBIX files or published Power BI Service dashboards.

## Use the report

1. Extract the complete Power BI bundle. Preserve its folders.
2. If it has moved, run `powerbi/Set-DataFolder.ps1` to set the data location, or edit the `DataFolder` parameter to the full path ending in `data/powerbi/`.
3. Open `powerbi/RetailPerformance.pbip` in Power BI Desktop with Power BI Project/PBIR support enabled.
4. Select **Refresh**. Compare the overview metrics with [metrics.json](outputs/metrics.json).
5. Try the date/category slicers. See [RUNBOOK.md](RUNBOOK.md) for validation and refresh details.

## Method and action

Invoice-line fact table, four conformed dimensions, single-direction relationships, 17 filter-aware DAX measures, and independently reconciled source totals.

Use the report to select a country and period, inspect credit exposure and customer coverage, then define a measurable retention experiment with a commercial owner.

This report extends the original retail case study using the same historical observations. Snapshot customer segments are fixed at 10 December 2011. Credits are not linked to original sales, and invoice value is not profit. Native Power BI refresh and rendering remain unverified because Desktop is not installed.

## Reproduce the analysis

Use the complete collection, with Python 3.12 and `requirements.txt` installed. From its root:

```powershell
python projects/101-retail-performance-powerbi/analysis.py
python -m powerbi.validate
```

Original source downloads and baseline analyses must exist first; the root README documents them. The [executed notebook](analysis.ipynb) displays the transformation code, reruns preparation, rebuilds native report files, and shows computed evidence. Shared implementation is in `powerbi/prepare.py`, `powerbi/author.py` and `powerbi/validate.py`.

## Sources and implementation references

- [UCI source dataset](https://archive.ics.uci.edu/dataset/352/online+retail), transformed and aggregated under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).
- [Microsoft: Power BI report project files](https://learn.microsoft.com/en-us/power-bi/developer/projects/projects-report).
- [Microsoft: semantic model project files](https://learn.microsoft.com/en-us/power-bi/developer/projects/projects-dataset).
- [Microsoft: gzip decompression in Power Query](https://learn.microsoft.com/en-us/powerquery-m/binary-decompress).

Related studies may reuse data and holdouts. No employment relationship, commercial uplift, current operational performance or causal effect is inferred.
