# Power Query, Data Validation and Repeatable Cleanup

> Automating imports and cleaning with Power Query, and preventing bad input with data validation rules. Free notes, key concepts, resources and a mini project.

Canonical: https://www.internhack.in/roadmaps/tracks/data-analyst/power-query-validation
Last updated: 2026-11-28

Automating imports and cleaning with Power Query, and preventing bad input with data validation rules.

Intermediate · about 5 hours · difficulty 3/5

Learn first: [Lookups: XLOOKUP, INDEX/MATCH and Friends](https://www.internhack.in/roadmaps/tracks/data-analyst/spreadsheet-lookups)

If you clean the same export every week by hand, you are doing a job Power Query should do. It records each transformation as a step, so next week you just click Refresh.

### Power Query essentials

- **Get Data** from CSV, folders of files, databases or web pages.
- Common steps: remove columns, change types, split columns, trim, replace values, filter rows, fill down, unpivot.
- **Merge** queries (joins) and **Append** queries (stacking files with the same shape).
- Every step is written in the M language; you rarely need to write M by hand but reading it helps debug.
- The same engine powers Power BI, so skills transfer directly.

### Data validation

When people type data into your sheets, stop mistakes at the door:

- Dropdown lists from a reference range.
- Numeric and date limits, custom formula rules.
- Input messages and error alerts that explain what is expected.
- Protect sheets so formulas cannot be overwritten.

### Deduplication and checks

Use Remove Duplicates carefully (decide which columns define a duplicate), and add check cells: row counts, totals that should match the source, counts of blanks.

**Pitfall:** Power Query type detection guessing wrong (e.g. treating product codes like "00123" as numbers). Always review the Changed Type step. Move on when you can combine a folder of monthly CSV files into one clean table with a single refresh.

## Key concepts

- **Importing from files, folders, web**
- **Type changes, split, trim, replace**
- **Merge and Append queries**
- **Unpivot columns**
- **Reading M code**
- **Data validation rules and dropdowns**
- **Sheet protection**
- **Control totals and check cells**

## Mini project

Download 12 monthly files of a public dataset (e.g. UK Land Registry price paid or a city's monthly transit ridership), combine them via Power Query From Folder, clean types, and produce a refreshable pivot.

## Check yourself

Why is Unpivot often the first step when a spreadsheet has one column per month?

## Free resources

- [Power Query documentation](https://learn.microsoft.com/en-us/power-query/) (Microsoft Learn)
- [Excel help and learning](https://support.microsoft.com/en-us/excel) (Microsoft)

Previous: [Charts and Simple Dashboards in Spreadsheets](https://www.internhack.in/roadmaps/tracks/data-analyst/spreadsheet-charts) · Next: [Descriptive Statistics](https://www.internhack.in/roadmaps/tracks/data-analyst/descriptive-statistics)

## More in Spreadsheets as a Serious Analysis Tool

- [Spreadsheet Foundations and Good Structure](https://www.internhack.in/roadmaps/tracks/data-analyst/spreadsheet-foundations)
- [Formulas and Functions That Matter](https://www.internhack.in/roadmaps/tracks/data-analyst/spreadsheet-formulas)
- [Lookups: XLOOKUP, INDEX/MATCH and Friends](https://www.internhack.in/roadmaps/tracks/data-analyst/spreadsheet-lookups)
- [Pivot Tables and Summary Reporting](https://www.internhack.in/roadmaps/tracks/data-analyst/pivot-tables)
- [Charts and Simple Dashboards in Spreadsheets](https://www.internhack.in/roadmaps/tracks/data-analyst/spreadsheet-charts)
- [Power Query, Data Validation and Repeatable Cleanup](https://www.internhack.in/roadmaps/tracks/data-analyst/power-query-validation)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Data Analyst Roadmap](https://www.internhack.in/roadmaps/tracks/data-analyst)
