Protected Learning Content

AICPE Gurukul content is created for learning purposes. Printing, copying and unauthorized reuse are restricted.

AICPE Learning Hub Advanced Excel
Chapter 23
Introduction to Power Query
Chapter 23 | Data Transformation

Introduction to Power Query

Move beyond repetitive copy-paste work. Learn how Excel can connect to source data, record transformation steps, produce a clean reporting table and repeat the same process whenever fresh data arrives.

ConnectBring data from tables, workbooks, text files, folders and other supported sources.
TransformClean, reshape, standardize and validate information through repeatable steps.
RefreshReapply the stored process when the source data changes.
LoadSend prepared results to a worksheet, connection or Data Model.
Practical level: Beginner to workplace-ready
Learning Objectives

After This Chapter, You Will Be Able To

Understand the Power Query workflow and create a refreshable data-cleaning process without depending on repeated manual edits.

Explain Power Query

Describe its purpose, business value and role inside an Excel reporting process.

Connect to Data

Recognize common source types and choose Transform Data instead of loading raw information directly.

Apply Transformations

Use data types, filters, column operations, replacements and cleaning steps inside the editor.

Load and Refresh

Send results to an appropriate destination and repeat the process safely when the source changes.

Power Query Foundation

Turn Manual Data Preparation into a Repeatable Process

Power Query is most valuable when the same type of data arrives repeatedly and must be cleaned in the same way.

1 What Power Query Does

Power Query is Excel's data connection and transformation experience. It helps users connect to a source, inspect the records, apply a sequence of cleaning or reshaping operations and load the prepared result for analysis.

The source remains separate from the transformation instructions. Instead of permanently changing the original file, the query stores a repeatable recipe. When fresh source data is available, refreshing the query runs that recipe again.

Definition: A query is a saved set of connection details and transformation steps that produces a structured output from one or more data sources.

Manual Method

Open files, copy rows, remove columns, fix dates, filter errors and repeat everything next month.

Power Query Method

Connect once, define steps, load the result and use Refresh when new source data arrives.

Business Benefit

Improved consistency, fewer accidental edits, documented logic and faster reporting cycles.

Professional Tip: Use Power Query for repeatable data preparation. Use worksheet formulas, PivotTables or the Data Model for analysis after the data has been shaped correctly.

Practical Experiment 1: Identify Repetitive Work

Select one report you prepare regularly and separate data-preparation work from analysis work.

Step 1: Observe

List every manual action performed before analysis begins.

Step 2: Classify

Mark actions such as importing, deleting, filtering, splitting, replacing and changing formats.

Step 3: Prioritize

Choose the workflow with the highest repetition and error risk.

Learning Output: A clear Power Query automation opportunity from your own office or business work.

2 Understand the Connect–Transform–Load–Refresh Cycle

A reliable Power Query solution follows a simple lifecycle. The learner should understand this lifecycle before exploring individual commands.

1

Connect

Select the source and establish access to its data.

2

Transform

Clean, filter, reshape, classify and validate the records.

3

Load

Place the prepared result in a worksheet, connection or Data Model.

4

Refresh

Re-run the stored process when the source is updated.

Source, Query and Output Are Different Layers

LayerPurposeRecommended Practice
SourceOriginal business records supplied by a system, user or file.Keep structure stable and avoid unnecessary manual changes.
QueryConnection and transformation instructions.Use clear names, logical step order and documented assumptions.
OutputPrepared table or model used by reports.Do not treat it as the permanent place for manual data entry.
ReportPivotTable, dashboard, chart or calculation built on prepared data.Reconcile totals after every major refresh.
Remember: Editing a loaded query output does not normally repair the source. On refresh, output rows can be replaced by the result generated from the source and saved steps.
Power Query Editor

Learn the Workspace Before Building Transformations

The editor displays a data preview, commands, query names and the sequence of Applied Steps.

3 Open Power Query and Understand the Editor

In Excel, Power Query commands are generally available through the Data tab under the Get & Transform Data area. The exact connector list can vary by Excel edition, platform and organizational configuration.

Queries Pane

Shows available queries and helps users select, rename, duplicate, reference or organize them.

Data Preview

Displays a sample view of the current query result after the selected step.

Ribbon

Contains Home, Transform, Add Column and View commands used to shape data.

Query Settings

Shows query properties and the ordered Applied Steps that produce the current output.

Important Ribbon Areas

AreaTypical WorkExample
HomeManage columns and rows, combine queries, choose load action.Remove Columns, Keep Rows, Close & Load.
TransformModify existing columns.Change type, split, replace, format, group.
Add ColumnCreate new derived information.Conditional, custom, index and example-based columns.
ViewInspect query logic and diagnostic information.Formula bar, column quality and query dependencies.
M Language: The editor automatically creates Power Query M expressions behind many interface actions. Beginners can build useful queries without writing M code, while advanced users can inspect or edit it later.

Practical Experiment 2: Explore the Editor

Convert a small worksheet range into an Excel Table, then open it through Data → From Table/Range.

Step 1: Connect

Select a table containing at least five columns and twenty records.

Step 2: Explore

Locate the preview, ribbon, formula bar, query name and Applied Steps.

Step 3: Document

Write one sentence describing the role of each interface area.

Learning Output: Confidence navigating the editor before applying transformations.

4 Applied Steps: The Recorded Transformation Recipe

Every transformation is recorded as a step in Query Settings. The result of one step becomes the input for the next step. This makes step order extremely important.

Source → Navigation → Promoted Headers → Changed Type → Filtered Rows → Removed Columns → Cleaned Text → Final Output

Manage Steps Professionally

  • Rename important steps so their business purpose is clear.
  • Use the gear icon, when available, to edit a step's settings.
  • Delete only after checking whether later steps depend on it.
  • Move steps cautiously because transformations may behave differently in another order.
  • Review the preview after each major change and verify row count, column count and totals.

Step Dependency

A later step may refer to a column or result created earlier.

Step Naming

Names such as “Filtered Active Customers” are clearer than generic automatically generated labels.

Step Testing

Click any step to inspect the data preview at that point in the process.

Practical Experiment 3: Test Step Order

Create a query with text cleaning, filtering and column removal, then observe how changing the order affects the result.

Step 1: Build

Apply at least four transformations.

Step 2: Compare

Move or recreate one step earlier in the sequence.

Step 3: Explain

Record why the output changed or why an error occurred.

Learning Output: Understanding that a query is an ordered process, not a disconnected list of commands.
Connect to Data

Select the Correct Source and Import Path

A stable source structure makes refreshable reporting easier to maintain.

5 Common Data Sources and the Navigator

Power Query can connect to many kinds of data. Common Excel workflows begin with worksheet tables, other Excel workbooks, text or CSV files, folders and organizational databases. Available connectors depend on the Excel environment.

SourceTypical UsePreparation Advice
Excel Table / RangeClean records already present in the current workbook.Use one header row and convert the range into a Table.
Excel WorkbookImport tables, named ranges or worksheet content from another file.Prefer structured tables and stable sheet or table names.
Text / CSVImport exports from billing, CRM, attendance or accounting systems.Check delimiter, encoding, decimal format and date interpretation.
FolderCombine similarly structured periodic files.Keep only intended files in the folder and standardize columns.
Database / Online ServiceConnect to governed enterprise or cloud information.Confirm credentials, permissions, privacy and refresh requirements.

Use the Navigator Carefully

The Navigator allows you to preview available objects. Select the correct table or object, inspect the preview, and choose:

Load

Imports the selected data with minimal or no editor work.

Transform Data

Opens the editor so the data can be cleaned before loading.

Combine

Available in suitable connectors such as folders, where similarly structured files can be processed together.

Source Stability Warning: Queries may fail when file paths, table names, sheet names, column names or source structures change unexpectedly.

Practical Experiment 4: Import a CSV File

Use a sample sales export containing dates, customer names, quantities and amounts.

Step 1: Preview

Check delimiter, headers and visible data quality.

Step 2: Transform

Open the editor instead of loading immediately.

Step 3: Validate

Confirm the row count and inspect data types.

Learning Output: A correctly connected query ready for transformation.

6 Data Profiling Before Transformation

Before cleaning records, inspect the dataset. Good transformations are based on evidence, not assumptions.

Column Quality

Review valid, error and empty proportions where profiling tools are available.

Column Distribution

Observe distinct and unique values to identify repetition and unusual categories.

Column Profile

Inspect detailed statistics and value distribution for the selected column.

Source Controls

Record rows, columns, date range, total amount and expected identifiers.

Quality Rule: Save control totals before transformation. After loading, reconcile the final output to the approved source scope and explain every deliberate exclusion.
Core Transformations

Clean and Reshape Data with Repeatable Steps

Begin with transformations that improve structure, consistency and analytical readiness.

7 Headers, Data Types and Column Management

Correct column structure is the foundation of a dependable query. Each column should represent one field and use a data type that matches its meaning.

TransformationUseExample
Use First Row as HeadersPromote the first data row into field names.Convert Column1, Column2 into Date, Customer.
Rename ColumnsApply clear and stable business names.CustNm → Customer Name.
Change Data TypeInterpret values correctly for calculations and comparisons.Text date → Date; text amount → Decimal Number.
Choose / Remove ColumnsKeep only fields required by the reporting purpose.Remove system notes and unused export columns.
Reorder ColumnsPlace key identifiers and measures logically.Invoice ID, Date, Customer, Product, Amount.
Data-Type Warning: A visually numeric column may still be text. Incorrect types can prevent sums, date grouping, relationships and comparisons from working correctly.

Practical Experiment 5: Repair Data Types

Create or import a table where dates, quantities and amounts are stored as text.

Step 1: Diagnose

Identify columns whose types do not match their business meaning.

Step 2: Convert

Apply suitable data types and inspect any resulting errors.

Step 3: Verify

Confirm that dates sort chronologically and amounts aggregate correctly.

Learning Output: An analytically usable table with controlled data types.

8 Clean Rows and Text Values

Many operational exports contain blank rows, totals, comments, repeated headings, inconsistent spaces, unwanted characters or mixed naming conventions. Power Query can record the cleaning process so it is repeated during refresh.

Row Operations

Remove top or bottom rows, blank rows, duplicates, errors or records outside the approved scope.

Filter Operations

Keep active records, valid dates, required branches or positive transaction amounts.

Text Operations

Trim spaces, clean non-printing characters, change case and replace inconsistent labels.

Typical Cleaning Sequence

Remove Report Title Rows → Promote Headers → Remove Blanks → Set Types → Trim/Clean Text → Standardize Categories → Filter Valid Scope → Remove Duplicates
Duplicate Control: Do not remove duplicates only because complete rows look identical. First define the business key—for example Invoice ID plus Line Number—and confirm whether repeated records are errors or legitimate transactions.

Practical Experiment 6: Clean a Customer Master

Use data containing spaces, inconsistent case, blank cities and duplicate customer codes.

Step 1: Standardize

Trim and clean text; apply appropriate case where useful.

Step 2: Validate

Filter blank identifiers and inspect duplicate codes.

Step 3: Reconcile

Compare starting rows, removed records and final rows.

Learning Output: A controlled customer master suitable for lookup, reporting or relationships.

9 Split, Merge, Replace and Add Useful Columns

Power Query can reshape fields so that each column represents one useful attribute. These operations are especially valuable when source systems export combined or coded information.

NeedSuitable OperationExample
Separate combined informationSplit Column by delimiter, position or character transition“Nagpur | West” → City and Region
Combine fieldsMerge ColumnsFirst Name + Last Name → Full Name
Standardize labelsReplace Values“Mum.” and “Bombay” → “Mumbai”
Create categoriesConditional ColumnAmount ≥ 100000 → High Value
Create row identityIndex ColumnSequential row number for traceability
Derive informationCustom ColumnQuantity × Rate → Line Value

Practical Experiment 7: Reshape an Order Export

Use a table containing “Customer - City”, product codes and transaction values.

Step 1: Split

Separate customer and city using the correct delimiter.

Step 2: Derive

Create a conditional value band or custom line-value column.

Step 3: Review

Check nulls, errors and row count after every transformation.

Learning Output: A reshaped transaction table ready for PivotTable or dashboard analysis.
Load and Refresh

Choose the Right Destination and Maintain the Query

The transformation is useful only when its result is loaded, refreshed and controlled appropriately.

10 Load Options

After completing the query, choose where the result should be used. The suitable option depends on data volume, analytical design and whether the query is an intermediate preparation step.

DestinationWhen to UseImportant Consideration
Table in WorksheetUsers need to view, filter or directly reference the prepared rows.Large outputs consume worksheet space and remain subject to worksheet limits.
Data ModelMultiple related tables or analytical measures will be used.Design clean keys, relationships and suitable data types.
Connection OnlyThe query supports another query or should not produce a visible table.Use clear names so dependencies remain understandable.
PivotTable / PivotChartA summarized analytical output is required.Confirm whether the source should be a worksheet table or the Data Model.
Design Principle: Avoid loading every staging or intermediate query to a worksheet. Load only the outputs required by users or the analytical model.

Practical Experiment 8: Compare Load Options

Create one cleaned sales query and test suitable destinations.

Step 1: Table

Load the prepared data to a worksheet and inspect the result.

Step 2: Connection

Create a duplicate or reference query and use connection-only loading.

Step 3: Decide

Explain which query users should see and which should remain behind the scenes.

Learning Output: A purposeful load strategy rather than a workbook filled with unnecessary output tables.

11 Refresh, Credentials and Source Changes

Refresh reconnects to the source and reapplies the saved transformations. A refreshable query still requires disciplined source management.

Refresh Behaviour

Updated source records are read and the transformation sequence runs again.

Credentials

Some sources require authentication and approved permissions before data can be retrieved.

Structural Change

Renamed, removed or newly formatted columns can affect later steps and cause errors.

Refresh Control Checklist

  • Confirm the source file, table or system is updated and accessible.
  • Refresh the required query or all relevant connections.
  • Review errors and warning indicators.
  • Reconcile row counts, totals, date range and key categories.
  • Update PivotTables, dashboards or dependent reports where required.
  • Record refresh date, source period, reviewer and version.
Do Not Enter New Source Records into the Loaded Output: Update the actual source. The next refresh can regenerate the output table and remove unsupported manual changes.

12 Query Naming, Documentation and Quality Controls

Professional workbooks are designed for maintenance. Names and documentation should explain the purpose of each query and its place in the workflow.

Query RoleExample NamePurpose
Raw / Sourcesrc_SalesCSVInitial connection with minimal changes.
Stagingstg_SalesCleanCleaning, typing and standardization.
Reference / Mappingmap_ProductCategoryControlled business mappings.
Final Outputout_MonthlySalesPrepared table used by the report.

Document Assumptions

Record source location, expected columns, exclusions, key definitions and refresh ownership.

Keep Controls

Track starting rows, removed errors, duplicates, final rows and control totals.

Protect Privacy

Use organizational permissions and approved privacy practices for confidential or combined sources.

AICPE Quality Learning Commitment: AICPE Gurukul promotes practical, skill-based and career-oriented learning for students, institutes and professionals. Learn more at aicpeindia.org and aicpe.online.
Interactive Learning Lab

Power Query Workflow Planner

Select your source, main data problem and intended output to receive a suggested beginner workflow.

Recommended starting point: Choose the source, problem and destination, then generate your query plan.
Real-Time Practical Assignment

Build a Refreshable Monthly Sales Import

Create a complete beginner-level Power Query process from raw source to management-ready output.

Project: Monthly Sales Data Preparation

Use a CSV or Excel source containing at least 100 transaction rows with fields such as Invoice ID, Invoice Date, Region, Salesperson, Customer, Product, Quantity, Rate, Discount and Status.

Step 1: Source Audit

Record source row count, date range, total amount, blank identifiers and duplicate keys.

Step 2: Connect

Import through Power Query and choose Transform Data.

Step 3: Structure

Promote headers, rename fields, remove unused columns and arrange key fields.

Step 4: Clean

Set data types, trim text, standardize labels and handle blanks or invalid rows.

Step 5: Derive

Create Line Value and a useful transaction category.

Step 6: Load

Load the final query to a worksheet table or the Data Model.

Step 7: Refresh Test

Add fresh records to the source and refresh the query.

Step 8: Reconcile

Verify rows, total values, exclusions, errors and refresh date.

Submission: Save the workbook with clearly named source, staging and output queries; include a Control sheet explaining each transformation and the final reconciliation.
Workplace Value: This project can become a portfolio sample for MIS, operations, accounts, administration or junior data-support roles.
Practice Worksheet

Complete These Power Query Activities

Use a separate practice workbook and record the result of every task.

1
Manual Process Audit

List ten repetitive data-preparation actions from one existing report.

Output: Automation opportunity sheet
2
From Table/Range

Convert a worksheet dataset into an Excel Table and open it in Power Query.

Output: Source query
3
CSV Import

Import a delimited file and verify headers, delimiter and data types.

Output: Import checklist
4
Text Cleaning

Trim, clean and standardize at least three text columns.

Output: Clean master table
5
Data-Type Repair

Correct text dates and text numbers; document conversion errors.

Output: Type validation report
6
Applied Steps Review

Rename five important steps and explain their order.

Output: Query step documentation
7
Load Decision

Choose worksheet, Data Model or connection-only for three scenarios.

Output: Load strategy note
8
Refresh Test

Add five valid records and one invalid record to the source; refresh and review.

Output: Refresh test evidence
9
Reconciliation

Compare source and output row counts, totals and exclusions.

Output: Control summary
10
Business Explanation

Write a five-line note explaining how the query reduces time and risk.

Output: Management summary
Practice Standard: A query is not complete until another person can understand its source, steps, output, refresh method and quality controls.
Common Mistakes

Mistakes Power Query Learners Should Avoid

Good query design protects refresh reliability and report accuracy.

Wrong Habits

  • Editing the loaded output instead of correcting the source or query.
  • Accepting automatic data types without verification.
  • Removing duplicates without defining a business key.
  • Using unstable source paths, sheet names or column names.
  • Deleting or reordering Applied Steps without checking dependencies.
  • Loading every intermediate query to a worksheet.
  • Refreshing without reconciling rows, totals and errors.
  • Leaving queries with unclear names such as Query1 and Table2.

Correct Habits

  • Maintain separate source, transformation and output layers.
  • Set data types according to business meaning.
  • Define duplicate rules before deleting records.
  • Use stable tables, files, paths and field names.
  • Keep steps logical, named and documented.
  • Use connection-only for suitable staging queries.
  • Apply refresh and reconciliation controls together.
  • Use meaningful role-based query names.
Remember: Automation repeats both good logic and bad logic. Validate the first result carefully before trusting repeated refreshes.
Quick Quiz

Check Your Power Query Understanding

Answer all 12 questions, submit your responses and review the explanations.

1. What is the strongest reason to use Power Query for a monthly report?

Power Query is especially useful when the same import and cleaning process must be repeated with fresh data.

2. Which sequence best represents a basic Power Query workflow?

The core lifecycle is to connect to data, transform it, load the output and refresh when the source changes.

3. Where are transformation instructions displayed in the editor?

Applied Steps records the ordered sequence used to produce the current query result.

4. Why does step order matter?

Moving or deleting a step can change the input available to later transformations.

5. What should you choose when data requires cleaning before it is loaded?

Transform Data opens the Power Query Editor so preparation steps can be applied before loading.

6. Which data-type choice is appropriate for a transaction date?

A valid Date type supports chronological sorting, filtering and date-based analysis.

7. Which operation helps remove leading and trailing spaces from text?

Trim removes unwanted leading and trailing spaces and helps standardize labels.

8. Before removing duplicates, what should be defined?

A business key identifies which combination of fields should be unique.

9. Which load option is suitable for an intermediate query used only by another query?

Connection-only loading is often appropriate for staging or supporting queries that do not need a visible worksheet table.

10. What happens during query refresh?

Refresh retrieves current source data and runs the recorded query process again.

11. What is a sensible control immediately after refresh?

A refreshed report must be checked against expected scope and control totals before use.

12. Which query name is most professional for a cleaned sales staging query?

A role-based name communicates that the query is a cleaned staging layer for sales data.
Quick Revision

Remember These Power Query Essentials

Revise the foundation before moving to advanced combining and reshaping techniques.

Separate Layers

Keep the original source, query logic, prepared output and final report conceptually separate.

Follow the Lifecycle

Connect, inspect, transform, load, refresh and reconcile.

Set Correct Types

Dates, numbers, text and logical values must match their business meaning.

Respect Step Order

Each Applied Step normally uses the result generated by the previous step.

Choose Load Purposefully

Use worksheet, Data Model or connection-only according to the analytical design.

Refresh with Controls

Verify rows, totals, errors, date range, exclusions and report version after refresh.