Rana Maninder Singh
Lesson 8 of 9Power BI

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

ResourceLink
PreviousAdvanced features
NextSQL + Power BI
Sample folderdata/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.csv

Breaking it down:

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:

Use this when: you're simulating the "finance drops a new CSV every month" workflow locally.


Tutorial 2 — Combine files in Power Query

  1. Get data → Folder.
  2. Browse to data/monthly_sales on your machine.
  3. Combine → Combine & Transform.
  4. Power Query shows Transform sample file — steps apply to all files.
  5. 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:

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

StepWhy
Promote headersEach file has same columns as sales
Set typesrevenue as number
Add column from file nameExtract 2022-01 from name if needed
Remove errorsBad rows from partial exports

Tutorial 4 — Load to model and relate

  1. Close & Apply → name table Sales Files.
  2. Relate to customers on customer_id (modelling).
  3. Build line chart: axis = file month or month column, values = sum revenue.

Tutorial 5 — Refresh when new month arrives

  1. Drop 2022-04.csv into the folder.
  2. 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.

StepWhereAction
1Power BI ServiceUpload .pbix or publish from Desktop
2Workspace → Dataset → SettingsScheduled refresh — set times (e.g. 6 AM daily)
3Gateway (if needed)On-prem CSV/SQL sources need a data gateway on a machine that can reach the files
4CredentialsRe-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 / actionWhat it does
Get Data → FolderCombine all files in a directory.
Combine & TransformApply same steps to every file.
Keep Source.Name columnNote which file each row came from.

Practice

Do this now

  1. Create data/monthly_sales/ with at least 3 CSV files.
  2. Combine via Folder connector; keep Source.Name.
  3. One visual proving all months appear.
  4. Save outputs/pbi08_folder.pbix.

Checklist

  • [ ] Folder combine shows all files
  • [ ] Refresh picks up a new file I added
  • [ ] Next: SQL + Power BI