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.
- Cleaning: Remove blank rows, trim and clean all text, remove duplicates, replace nulls and errors, fill down and fix UK dates.
- Reshaping: Split columns, text before/after a delimiter, unpivot and pivot.
- Summaries: Group by, % of total and a fast running total.
- Combining: Merge (like VLOOKUP), append, and combine every CSV or Excel file in a folder.
Every snippet was checked with Microsoft's official Power Query parser, so the syntax is valid.