Folder Problem
Lesson opener
In one line: Load many files from one folder - the classic “monthly business exports” pattern (Jan.csv, Feb.csv, …).
Why it matters: This shows up at work when you need to load many files from one folder - the classic “monthly business exports” pattern (Jan.csv, Feb.csv, …)..
Before this lesson: Advanced features
Before you start
| Resource | Link |
|---|---|
| Previous | Advanced features |
| Next | SQL + Power BI |
| Sample folder | data/monthly_sales/ (created below in tutorial) |
Learning roadmap
On the website, this lesson shows an interactive roadmap (step strip, skills, link to course roadmaps references). Open Course → Roadmaps for the visual path.
What you will learn
Load many files from one folder — the classic “monthly business exports” pattern (Jan.csv, Feb.csv, …).
Tutorial 1 — Prepare a sample folder in this repo
On disk, create:
[Monthly sales folder structure]
WHY The folder connector expects one file per period with the same columns — this mirrors real finance drops.
WHEN Create this folder layout before using Get Data → Folder in Power BI.
data/monthly_sales/
2022-01.csv
2022-02.csv
2022-03.csvBreaking it down:
data/monthly_sales/— single folder Power BI will watch2022-01.csv, etc. — one CSV per month, same schema as sales.csv
Use this when: simulating how monthly exports arrive and you need a realistic folder to point the connector at.
Each file can be a subset of sales.csv filtered by month, or copy the same structure with different month values.
Quick PowerShell (run from repo root):
[Split sales CSV by month]
WHY You need separate monthly files on disk before Power BI's folder connector can combine them.
WHEN Run once from repo root to seed the monthly_sales folder.
New-Item -ItemType Directory -Force -Path data/monthly_sales
Import-Csv data/sales.csv | Group-Object month | ForEach-Object {
$_.Group | Export-Csv "data/monthly_sales/$($_.Name).csv" -NoTypeInformation
}Breaking it down:
New-Item— creates the output directoryGroup-Object month— splits sales rows by month valueExport-Csv— writes one file per month group
Use this when: you're simulating the "finance drops a new CSV every month" workflow locally.
Tutorial 2 — Combine files in Power Query
- Get data → Folder.
- Browse to
data/monthly_saleson your machine. - Combine → Combine & Transform.
- Power Query shows Transform sample file — steps apply to all files.
- Keep column Source.Name (file name) for audit trail.
Example M (concept):
[Folder.Files connector]
WHY This M function lists every file in a folder — the starting point for combine-from-folder queries.
WHEN Reference after choosing Get Data → Folder in the UI.
= Folder.Files("C:\Users\YourName\Documents\monthly_sales")Breaking it down:
Folder.Files(path)— returns a table of file metadata and content connectors
Use this when: monthly exports land in one shared folder and you don't want to union files by hand.
(Replace with your actual folder path — Power BI stores the local path in the query. On this lab PC the sample files live under data\monthly_sales inside your clone.)
Tutorial 3 — Clean combined table
| Step | Why |
|---|---|
| Promote headers | Each file has same columns as sales |
| Set types | revenue as number |
| Add column from file name | Extract 2022-01 from name if needed |
| Remove errors | Bad rows from partial exports |
Tutorial 4 — Load to model and relate
- Close & Apply → name table
Sales Files. - Relate to
customersoncustomer_id(modelling). - Build line chart: axis = file month or
monthcolumn, values = sum revenue.
Tutorial 5 — Refresh when new month arrives
- Drop
2022-04.csvinto the folder. - Home → Refresh — new month appears without rewriting the report.
Scheduled refresh (Power BI Service)
Desktop refresh (above) runs on your PC. Scheduled refresh runs in the cloud after you Publish to Power BI Service.
| Step | Where | Action |
|---|---|---|
| 1 | Power BI Service | Upload .pbix or publish from Desktop |
| 2 | Workspace → Dataset → Settings | Scheduled refresh — set times (e.g. 6 AM daily) |
| 3 | Gateway (if needed) | On-prem CSV/SQL sources need a data gateway on a machine that can reach the files |
| 4 | Credentials | Re-enter source login under Data source credentials |
Plain English: The folder connector stores a path on your laptop. In the cloud, that path does not exist — IT maps a gateway to \\fileserver\finance\monthly_sales\ instead. For learning, local refresh is enough; know scheduled refresh exists for production.
Essential commands
| Command / action | What it does |
|---|---|
Get Data → Folder | Combine all files in a directory. |
Combine & Transform | Apply same steps to every file. |
Keep Source.Name column | Note which file each row came from. |
Practice
Do this now
- Create
data/monthly_sales/with at least 3 CSV files. - Combine via Folder connector; keep Source.Name.
- One visual proving all months appear.
- Save
outputs/pbi08_folder.pbix.
Checklist
- [ ] Folder combine shows all files
- [ ] Refresh picks up a new file I added
- [ ] Next: SQL + Power BI