Power Query in Excel
Phase 1 goal
Turn Excel from a calculation grid into a repeatable data pipeline: clean data with Power Query, look up and reshape with modern functions, wrap logic in LET/LAMBDA, and summarize with PivotTables on a Data Model.
π― Learning objectives
Tick each one when you can actually do it.
π‘ Key concepts
- ETL mindset: Extract (Get Data) β Transform (Power Query Editor) β Load (Table, PivotTable, or Data Model). The steps are recorded, so next month you just click Refresh.
- Applied Steps pane. Each step is a line of M.
- Essential transforms: Promote headers, Remove top rows, Change type, Trim/Clean, Replace values, Split column, Fill down, Conditional column, Remove duplicates, Group By.
- Unpivot: Turns
Oct | Nov | Deccolumns intoMonth | Valuerows (the most important reshape for budget data). - Merge vs. Append: Merge = join (like XLOOKUP for whole tables: Left Outer, Inner, Anti for "what's missing"). Append = stack tables with the same columns.
- From Folder: Combine every monthly status file automatically, so a new file dropped into the folder gets picked up on refresh.
- Data types and locale: Set types explicitly. Use "Using Locale" for odd date formats.
- Error handling: "Replace Errors", "Keep Errors" (to audit), and in M,
try β¦ otherwise. - Parameters: Store the folder path as a parameter so the workbook is portable.
π Hands-on exercise: Tame the Status Drops
Data: status_drops/ folder (D8). Headers vary; columns roughly include ProgramID, Milestone, Fcst Dt / Forecast Date, RAG, Cost columns as text, month columns OctβSep.
- Data β Get Data β From Folder β Combine & Transform.
- In the sample-file transform: remove the top 3 title rows, promote headers, and remove blank rows.
- Standardize headers: rename variants to
ForecastDate(tip: one rename step with a list, or theTable.RenameColumnsMissingField.Ignoreoption. Look at it in the Advanced Editor). - Clean RAG: Trim, Uppercase, then map
G/GREEN/GRNβGreen, etc. (Conditional Column or Replace Values). - Dates: convert text to date. Turn
TBDandQ3 FY26into null (Replace Errors β null). Add aDateQualityFlagcolumn. - Money: write a custom column that converts
$1.2M,450K,1,250,000into numbers:let t = Text.Upper(Text.Remove([CostText], {"$", ",", " "})), mult = if Text.EndsWith(t, "M") then 1000000 else if Text.EndsWith(t, "K") then 1000 else 1, num = try Number.From(Text.TrimEnd(t, {"M","K"})) otherwise null in if num = null then null else num * mult - Unpivot the OctβSep columns into
FYMonthName/Amount, then addFYMonth(Oct=1 β¦ Sep=12). - Merge with
programsto bring in Portfolio. Load to a Table namedStatusClean. - Drop a new month's file into the folder and Refresh. Confirm it shows up.
π¦ Mini-project: Contracts Health Query
Build a query pipeline that (a) merges contracts with a rollup of budget_execution obligations, (b) uses an Anti join to list contracts with no obligation activity in the last 90 days, and (c) adds PoPDaysRemaining and % Ceiling Obligated. Load it to a formatted Table plus a small summary.
π§ Self-check quiz
Answer in your own words, then check. Grade yourself honestly; your score is saved.
try β¦ otherwise do in M?