Power Query Snippets

Ready-made Power Query (M) code for Excel and Power BI. Type your column names, then copy the code.

🔒 Runs in your browser⚡ Instant results👤 No sign-up⭐ Downloads with Pro

Power Query (M) code you can copy and paste

Power Query in Excel and Power BI records your clicks as M code, but some of the most useful steps are hard to click together. This library gives you tested M code for the jobs analysts do every day. Type your column names and the code updates instantly.

Every snippet was checked with Microsoft's official Power Query parser, so the syntax is valid.

Frequently asked questions

Where do I paste this?

In Excel: Data → Get Data → Launch Power Query Editor. In Power BI: Home → Transform data. Then Home → Advanced Editor. Paste the steps before the word "in", add a comma after the previous step and update the name after "in".

Why does my date column show errors?

Text dates like 03/04/2026 are read using your computer's language. Use the "Fix UK dates" snippet, which tells Power Query to read them as day/month/year.

What is the "previous step name"?

Each Power Query step uses the result of the step before it. Type the name of the step you want to build on, as it appears in the Applied Steps list.

More data analysis & spreadsheet tools

📊
Excel Data AnalyserInstant KPI dashboard, insights, report & slides
📈
Instant DashboardPower BI style dashboard from any Excel file
🔁
CSV ↔ Excel ConverterConvert CSV, XLSX, XLS, ODS and JSON
🧩
Excel File MergerCombine many spreadsheets into one
🧹
Duplicate RemoverFind and delete duplicate rows
📈
Chart MakerPaste data, get a chart, download PNG or PowerPoint
🗄️
Excel to SQLCREATE TABLE & INSERT statements from any spreadsheet
🧮
SQL Query BuilderBuild SQL with clicks, explained in English, run on your data
✨
SQL FormatterMake messy SQL clean and readable
🧽
Data CleanerFix spaces, capitals, text numbers, dates, blanks and duplicates
🔗
VLOOKUP / Merge Two SheetsMatch two files on a shared column, no formulas
🆚
Compare Two Excel FilesSee added, removed and changed rows and cells
🧊
Pivot Table BuilderGroup, total and chart your data with clicks
🌐
Web Table to ExcelCopy tables from websites into clean Excel
🔣
JSON ↔ Excel ConverterFlatten JSON into a spreadsheet, or Excel into JSON
📍
UK Postcode Lookup (Bulk)Add council, region and lat/long to postcodes
🔄
Unpivot / Reshape DataColumns to rows and back, ready for Power BI
🎯
Outlier FinderSpot unusual values, typos and errors
📐
Statistics CalculatorMean, SD, correlation, t-test, chi-square explained
🎲
Random Sample PickerRandom rows for audits, surveys and prize draws
🧠
DAX Measure GeneratorYTD, YoY %, rank and % of total for Power BI
📅
Date Table GeneratorPower BI / Excel calendar with UK bank holidays
🧩
Excel Formula BuilderXLOOKUP, SUMIFS, IF and more in plain English
⚙️
Power Query SnippetsCopy-paste M code to clean and reshape data
🗄️
SQL PlaygroundRun SQL queries and JOINs on Excel & CSV files
🐘
Large CSV ViewerOpen & filter CSVs with millions of rows
✂️
Split Excel by ColumnOne sheet or file per region, rep or month
🔗
Fuzzy Match (Fuzzy VLOOKUP)Match similar names between two lists
🛡️
Data AnonymiserMask, hash or code personal data for GDPR
📇
Extract Emails, Phones & PostcodesPull contact details out of any text or file
🔮
Forecast & RegressionSales forecast and what drives your numbers
👑
RFM Customer SegmentsFind champions, loyal and at-risk customers
📊
Cohort RetentionHow many customers come back month by month
🅰️
ABC / Pareto AnalysisThe 20% of products that make 80% of sales
⚖️
A/B Test CalculatorIs version B really better? p-value and sample size
🧪
Test Data GeneratorRealistic fake UK data for testing and demos

See all 123 tools →