Power BI · Power Query · Data Transformation

Power BI Power Query:
Data Transformation for Finance
Clean ERP Exports in Minutes, Not Days

By Dr. Hesham Mokhiemer — The Financeer Academy Published January 2026 Reading time ~20 min Level Intermediate–Advanced
Dr. Hesham Mokhiemer

Dr. Hesham Mokhiemer

Global Distinguished Trainer · IFRS · Financial Modelling · Power BI · CMA Prep

Founder of The Financeer Academy. Trains GCC finance teams on Power BI — with deep focus on the data transformation layer that determines whether a dashboard takes 3 hours or 3 minutes to refresh.

Every GCC finance team I work with has the same problem: their ERP export is a mess. P&L data is pivoted with months as columns. Account codes and descriptions are in one merged cell. Budget is in a separate file with different column names. Three subsidiaries export in slightly different formats. Before you write a single DAX measure, you need Power Query to transform this chaos into a clean, consistent star schema. This post teaches you exactly how.

What you will master in this post

  • Navigate the Power Query interface and understand the Applied Steps pane — your transformation audit trail
  • Unpivot wide P&L tables (months as columns) into the long format that DAX requires
  • Fix data types, replace errors, handle null values from SAP/Oracle exports automatically
  • Merge the Actuals query with the Budget query — building a unified fact table in one step
  • Append 12 monthly files into a single table without manual copy-paste
  • Write custom M code columns for account hierarchy, fiscal year flags, and entity codes
  • Use Parameters for dynamic file paths — so the dashboard works on any machine

Why Power Query is the Most Important Skill in the Finance BI Stack

Finance teams spend 80% of their Power BI time on data preparation and 20% on dashboard building. It should be the other way around. Power Query — the ETL layer inside Power BI — automates the entire data cleaning and shaping process. Once built, transformations run automatically every time you click Refresh. The SAP export that used to take 3 hours to manually clean and reshape in Excel now takes 8 seconds.

Power Query uses the M language — a functional programming language that is fully auditable (every transformation is a step you can see, edit, or delete), repeatable (the same steps run on every refresh), and document-able (other team members can read and maintain your logic).

M
Power Query M language — functional, auditable, fully repeatable
Applied Steps
Every transformation is a named, editable, deletable step — full audit trail
Auto-refresh
All transformations run automatically on every data refresh — zero manual work

Power Query Interface — The Three Panels You Must Know

1

Queries pane (left)

Lists all your queries — Actuals, Budget, dDate, dAccount, dEntity. Organise them into folders: Fact Tables, Dimension Tables, Staging (intermediate queries not loaded to the model). Staging queries reduce duplication — define a transformation once and reference it from multiple downstream queries.

2

Applied Steps pane (right)

Every action you take in Power Query creates a named step — Source, Promoted Headers, Changed Type, Removed Columns, Unpivoted Other Columns, etc. Each step is a line of M code. Click any step to see the data at that point. Delete a step to undo it. Rename steps to document what they do.

3

Formula bar (top)

Shows the M code for the selected step. You can edit it directly — this is where you graduate from point-and-click to writing M. Most finance transformations are accomplished with 10–15 standard functions. You do not need to memorise the entire M language.

Cleaning a Typical SAP/Oracle Finance Export

A typical SAP GL or Oracle Financials export for GCC companies arrives as a wide table — account codes in rows, months (Jan, Feb, Mar…) as columns. This format is great for humans to read but impossible for DAX to work with. The fix is Unpivot.

Step 1: Unpivoting P&L Data

BEFORE — Wide Format (ERP Export)
Account | Jan-25 | Feb-25 | Mar-25 | … Revenue | 8,200 | 8,450 | 9,100
COGS | (4,100) | (4,200) | (4,500)
SG&A | (1,200) | (1,250) | (1,300)
⚠ DAX cannot aggregate across month columns
AFTER — Long Format (Star Schema Ready)
Account | Month | Amount Revenue | Jan-25 | 8,200
Revenue | Feb-25 | 8,450
COGS | Jan-25 | (4,100)
✓ One row per account per month — DAX-ready
// Full code is gated.
// Enrol in Power BI Mastery to access
// the complete copy-paste-ready implementation.

Full code is gatedCopy-paste-ready — available inside Power BI Mastery

Unlock Full Code — Power BI Mastery →
// Measure logic hidden — enrol in Power BI Mastery to get
// the complete, copy-paste-ready code for this calculation.
// Preview: this measure uses CALCULATE with filter context
// to return the correct value for each visual in your dashboard.

Full code is gatedCopy-paste-ready code — available inside Power BI Mastery

Unlock Full Code — Power BI Mastery →

Full code is gatedCopy-paste-ready code — available inside Power BI Mastery

Unlock Full Code — Power BI Mastery →

Step 2: Fixing Data Types from ERP Exports

The most common data quality failure in SAP/Oracle exports: Amount columns exported as Text because of thousands separators (commas) or currency symbols (SAR, $). Power Query treats "8,200" as text, not a number — so your SUM() returns blank. Fix: Replace Values (remove comma and currency symbol) → then Change Type to Decimal Number. Build this into your query so it runs automatically on every refresh.
// Full code is gated.
// Enrol in Power BI Mastery to access
// the complete copy-paste-ready implementation.

Full code is gatedCopy-paste-ready — available inside Power BI Mastery

Unlock Full Code — Power BI Mastery →
// Measure logic hidden — enrol in Power BI Mastery to get
// the complete, copy-paste-ready code for this calculation.
// Preview: this measure uses CALCULATE with filter context
// to return the correct value for each visual in your dashboard.

Full code is gatedCopy-paste-ready code — available inside Power BI Mastery

Unlock Full Code — Power BI Mastery →

Full code is gatedCopy-paste-ready code — available inside Power BI Mastery

Unlock Full Code — Power BI Mastery →

Step 3: Handling Nulls and Errors

// Full code is gated.
// Enrol in Power BI Mastery to access
// the complete copy-paste-ready implementation.

Full code is gatedCopy-paste-ready — available inside Power BI Mastery

Unlock Full Code — Power BI Mastery →
// Measure logic hidden — enrol in Power BI Mastery to get
// the complete, copy-paste-ready code for this calculation.
// Preview: this measure uses CALCULATE with filter context
// to return the correct value for each visual in your dashboard.

Full code is gatedCopy-paste-ready code — available inside Power BI Mastery

Unlock Full Code — Power BI Mastery →

Full code is gatedCopy-paste-ready code — available inside Power BI Mastery

Unlock Full Code — Power BI Mastery →

Merging Actuals with Budget — Building a Unified Fact Table

The cleanest approach for a finance dashboard: keep Actuals and Budget as separate queries, then merge them in a third query to create a single unified fact table. This avoids DAX complexity from maintaining two separate fact tables with different relationship paths.

// Full code is gated.
// Enrol in Power BI Mastery to access
// the complete copy-paste-ready implementation.

Full code is gatedCopy-paste-ready — available inside Power BI Mastery

Unlock Full Code — Power BI Mastery →
// Measure logic hidden — enrol in Power BI Mastery to get
// the complete, copy-paste-ready code for this calculation.
// Preview: this measure uses CALCULATE with filter context
// to return the correct value for each visual in your dashboard.

Full code is gatedCopy-paste-ready code — available inside Power BI Mastery

Unlock Full Code — Power BI Mastery →

Full code is gatedCopy-paste-ready code — available inside Power BI Mastery

Unlock Full Code — Power BI Mastery →
Dr. Hesham Mokhiemer Dr. Hesham MokhiemerGlobal Distinguished Trainer · The Financeer Academy

Get the complete Power Query finance pipeline — Power BI Mastery exclusive

The full .pbix file with pre-built Power Query transformations for SAP/Oracle exports, budget merge, date table generation, and parameter-driven file paths — exclusively for Power BI Mastery students.

Enrol in Power BI Mastery →

Appending Multiple Monthly Files Automatically

Many GCC companies receive monthly finance exports as separate files (Jan_2025.xlsx, Feb_2025.xlsx, etc.). Power Query's Folder connector lets you point to a folder and automatically combine all files — no manual copy-paste, and new files added to the folder appear automatically on the next refresh.

// Full code is gated.
// Enrol in Power BI Mastery to access
// the complete copy-paste-ready implementation.

Full code is gatedCopy-paste-ready — available inside Power BI Mastery

Unlock Full Code — Power BI Mastery →
// Measure logic hidden — enrol in Power BI Mastery to get
// the complete, copy-paste-ready code for this calculation.
// Preview: this measure uses CALCULATE with filter context
// to return the correct value for each visual in your dashboard.

Full code is gatedCopy-paste-ready code — available inside Power BI Mastery

Unlock Full Code — Power BI Mastery →

Full code is gatedCopy-paste-ready code — available inside Power BI Mastery

Unlock Full Code — Power BI Mastery →

Custom Columns — Adding Business Logic in M

// Full code is gated.
// Enrol in Power BI Mastery to access
// the complete copy-paste-ready implementation.

Full code is gatedCopy-paste-ready — available inside Power BI Mastery

Unlock Full Code — Power BI Mastery →
// Measure logic hidden — enrol in Power BI Mastery to get
// the complete, copy-paste-ready code for this calculation.
// Preview: this measure uses CALCULATE with filter context
// to return the correct value for each visual in your dashboard.

Full code is gatedCopy-paste-ready code — available inside Power BI Mastery

Unlock Full Code — Power BI Mastery →

Full code is gatedCopy-paste-ready code — available inside Power BI Mastery

Unlock Full Code — Power BI Mastery →

Parameters — Dynamic File Paths

The file path problem: If you hard-code "C:\Khalid\Finance\SAP_Export.xlsx" in your query and share the file with a colleague, it breaks immediately on their machine. The fix: use a Power Query Parameter for the base folder path. One parameter, referenced in all queries. To change the source location, update the parameter once — all queries update automatically.
// Full code is gated.
// Enrol in Power BI Mastery to access
// the complete copy-paste-ready implementation.

Full code is gatedCopy-paste-ready — available inside Power BI Mastery

Unlock Full Code — Power BI Mastery →

Full code is gatedCopy-paste-ready — available inside Power BI Mastery

Unlock Full Code — Power BI Mastery →

Leave a Comment

Share your Power Query experience. Register or log in to comment.

Article Author: Dr. Hesham Mokhiemer

To learn more about the author's professional details and experience, you can visit Dr. Hesham's Personal Profile Page.

JOB APPLICATION

The-Financeer-Main-Logo

The Financeer Academy

Where Finance Professionals Build Their Future

ALL RIGHTS RESERVED THE FINANCEER ACADEMY [2026]

The Financeer AI
Online — Your Finance Learning Assistant

You've reached your free limit 🎓

Create a free account to keep chatting with The Financeer AI with no limits.

Create Free Account Sign In