Power QueryExercises

Rename columns from a mapping table (ledger)

Finance keeps a two-column table of old and new column names. Apply it, ignoring names the export doesn't have.

Level
advanced
Time
~9 min
Task
Build the query
Access
Free — no account needed
Loading the practice workspace…

About this exercise

What you'll practise

Drive renaming from data (a mapping table) and tolerate mappings that don't apply.

Brightline Advisory (fictional) receives ledger exports from several client systems and maps their column names to its own standard.

Steps

  1. Mapping has columns Old and New. Rename every column of Export whose name appears in Old to the matching New.
  2. Some Old names don't exist in this export; ignore them. Columns not in the mapping keep their names.
  3. Don't type any column names into the query.

Your result must

  • Mapped columns renamed
  • Unmapped columns unchanged
  • Mappings for missing columns don't cause errors

Input

  • Export (table)
    • cr: text
    • desc: text
    • dr: text
    • acct: text
    • ref: text
  • Mapping (table)
    • Old: text
    • New: text

Expected output columns

cr (text), Description (text), Debit (text), Account (text), ref (text)

First 3 of 5 expected rows
crDescriptionDebitAccountref
cr-1desc-1dr-1acct-1ref-1
cr-2desc-2dr-2acct-2ref-2
cr-3desc-3dr-3acct-3ref-3