MICROSOFT POWER BI • DATA PREPARATION WITH POWER QUERY

Appending Queries — Append queries (union rows) and validate schema alignment (intro)

Learn to vertically stack tables from disparate sources while enforcing schema consistency in Power Query.

Historical Context & Motivation

The need to combine rows from multiple tables into a single, coherent dataset is one of the oldest problems in data management. In relational algebra, this operation is formalized as the union operator, which Edgar F. Codd described in his foundational 1970 paper on the relational model of data. The union requires both relations to be union-compatible—possessing the same number of attributes with matching domains—a constraint that Power Query inherits and extends in its Append Queries feature. As enterprise analytics matured through the 2000s, organizations increasingly stored logically related data across separate files, databases, and cloud endpoints, making vertical concatenation a daily ETL necessity.

1970
Codd's Relational Model
Edgar F. Codd publishes "A Relational Model of Data for Large Shared Data Banks," formalizing the union, intersection, and difference operators that underpin modern append operations.
1986
SQL UNION Standardized
The ANSI SQL standard introduces the UNION and UNION ALL keywords, giving analysts a declarative syntax for vertically combining result sets from compatible queries.
2010
Power Query Emerges
Microsoft releases Power Query (initially as a free Excel add-in) with a visual interface for data mashups, including the Append Queries command powered by the M language function Table.Combine.
2015
Power BI Desktop Launch
Power BI Desktop ships with the Power Query Editor integrated, making append and merge operations accessible to a broad audience of analysts and data engineers.
2020s
Dataflows & Cloud ETL
Power BI Dataflows extend Power Query to the cloud, enabling append operations on streaming data, paginated API results, and lakehouse tables at enterprise scale.

Despite decades of tooling evolution, the fundamental question remains the same: how do you stack rows from two or more tables while ensuring that the resulting schema is correct and no data is silently lost or misaligned? Power Query's Append Queries feature answers this question with a visual workflow, but understanding the underlying mechanics—especially schema alignment—is essential to avoiding subtle bugs in your data models.

Core Principles & Definitions

Before diving into the Power Query interface, it is important to establish the conceptual vocabulary that governs append operations. The append operation is a vertical concatenation: it takes all rows from a second table and places them beneath the rows of the first table, producing a new table whose row count equals the sum of the source row counts (analogous to SQL's UNION ALL). Unlike a merge (a horizontal join on key columns), an append adds no new columns from the secondary table that do not already conceptually belong to the schema. Power Query performs this through the M function Table.Combine, which takes a list of tables and produces a single output table.

1

Append (Union Rows)

Stacks rows from two or more tables vertically. The output row count is the sum of all source row counts. Columns are matched by name, not by position.
2

Schema Alignment

The process of verifying that source tables share the same column names and compatible data types before appending. Misaligned schemas produce null-filled columns.
3

Append Two vs. Append Three+

Power Query offers both a binary append (two tables) and an n-ary append (three or more tables). Both generate the same underlying M code using Table.Combine with a list argument.
4

Column Name Matching

Power Query matches columns by exact name (case-sensitive). If Table B has a column absent from Table A, that column is added to the result and filled with null for Table A's rows.
5

Append as New vs. In-Place

"Append Queries as New" creates a fresh query containing the union. "Append Queries" appends directly into the active query. The former is preferred for traceability.
KEY TAKEAWAY
Think of appending as stacking printed spreadsheets on top of each other. If both sheets have identical column headers, every row lines up perfectly—like stacking trays in a cafeteria. But if one sheet has an extra column or a misspelled header, you effectively get a tray that doesn't fit the slot, and the system compensates by inserting blanks (nulls). Validating schema alignment beforehand is the quality check that ensures every tray fits before you stack.

Visual Explanation — The Append Operation

The diagram shows two source tables with identical schemas (ID, Product, Revenue) being vertically combined into a single result table. The thin purple divider in the result indicates where Table A's rows end and Table B's rows begin. Note that the output preserves all five rows and all three columns.

In the diagram above, both source tables share an identical schema—three columns named ID, Product, and Revenue—so the append produces a clean result with no nulls. This is the ideal case. In practice, you will frequently encounter tables whose schemas diverge: a column may be named revenue in one table and Revenue in another (recall that M is case-sensitive), or one table may include an extra Region column that the other lacks. The next section examines what happens in those scenarios.

How Append Works Under the Hood

When you invoke Append Queries in the Power Query Editor, the GUI generates M code that calls Table.Combine. Understanding the semantics of this function illuminates why schema alignment matters. Table.Combine accepts a list of tables and an optional set of columns (a table type) that defines the output schema. If no explicit schema is provided, Power Query infers the output schema by computing the union of all column names across all input tables. Any column that exists in one table but not another will be filled with null for the rows originating from the table that lacks it.

The M Code Behind an Append

Consider two queries, Sales_Q1 and Sales_Q2. After appending them via the GUI, the generated step in the formula bar reads: = Table.Combine({Sales_Q1, Sales_Q2}). For an n-ary append of three or more tables, the list simply grows: = Table.Combine({Sales_Q1, Sales_Q2, Sales_Q3}). Because Power Query evaluates lazily, no data is physically copied until the query is loaded or refreshed.

OUTPUT ROW COUNT
|R| = |T₁| + |T₂| + … + |Tₙ|
Where |R| is the row count of the result, and |Tᵢ| is the row count of the i-th input table. Unlike SQL UNION (which deduplicates), Power Query's append behaves like UNION ALL — duplicates are preserved.
OUTPUT COLUMN SET
Columns(R) = Columns(T₁) ∪ Columns(T₂) ∪ … ∪ Columns(Tₙ)
The output schema is the set union of all column names. For every row from table Tᵢ, any column in Columns(R) \ Columns(Tᵢ) is filled with null.

Type Coercion Behavior

When two tables share a column name but differ in data type—say, Revenue typed as Int64.Type in Table A and Currency.Type in Table B—Power Query will attempt to promote the column to a common supertype. If no safe promotion exists, the column may revert to Any.Type, which defers type errors until downstream transformations or model load. Detecting and resolving these mismatches proactively is a core goal of schema validation.

Schema Alignment — Classification of Mismatches

Schema misalignment is the most common source of bugs in append workflows. Understanding the categories of mismatches allows you to detect and remediate them systematically. The following diagram illustrates three classes of schema mismatch and their consequences in an appended result.

This diagram classifies the three most common schema mismatches encountered when appending queries in Power Query: (1) a missing column that introduces nulls, (2) a column name discrepancy caused by case sensitivity that splits a logical column into two physical columns, and (3) a data type conflict that forces type promotion. The bottom section summarizes the five-point schema validation checklist.
Summary of schema mismatch categories and remediations
Mismatch TypeRoot CauseConsequence in ResultRemediation
Missing ColumnOne table lacks a column present in the other.Column added to result; rows from the lacking table filled with null.Add the column manually before appending, or remove the extra column if not needed.
Name MismatchColumn names differ in casing (e.g., Revenue vs. revenue) or spelling.Two separate columns appear in the result, each half-populated with nulls.Rename columns in each source query to use consistent naming before appending.
Type MismatchSame column name but different data types across tables.Column promoted to Any.Type; errors surface during model load or DAX calculation.Explicitly cast columns to matching types using Change Type before appending.

Worked Example — Appending Monthly Sales Tables

Suppose you receive three CSV files—Sales_Jan.csv, Sales_Feb.csv, and Sales_Mar.csv—each containing daily sales records for a retail chain. The January and February files share columns Date, Store, Product, and Revenue. However, the March file introduces a fifth column Discount and has revenue (lowercase) instead of Revenue. Our goal is to produce a single, clean, appended query with no null columns.

Appending Three Monthly Sales Files with Schema Alignment
1
Step 1 — Import All Three FilesUse Get Data → Text/CSV to import each file into Power Query. This creates three queries: Sales_Jan, Sales_Feb, and Sales_Mar. Each query appears in the Queries pane on the left side of the Power Query Editor.
2
Step 2 — Inspect SchemasClick on each query and examine the column names and types. Jan and Feb have columns [Date (date), Store (text), Product (text), Revenue (currency)]. Mar has [Date (date), Store (text), Product (text), revenue (text), Discount (number)]. We identify two issues: (a) revenue vs. Revenue name mismatch, and (b) Discount is missing from Jan and Feb.
Identified: name mismatch (revenue → Revenue) and missing column (Discount).
3
Step 3 — Fix the Name Mismatch in Sales_MarSelect the Sales_Mar query. Double-click the revenue column header and rename it to Revenue. Then use Change Type to set it as Currency. In M this is: = Table.RenameColumns(PreviousStep, {{"revenue", "Revenue"}}).
Sales_Mar now has column "Revenue" (currency), matching Jan and Feb.
4
Step 4 — Handle the Extra Discount ColumnWe have two options: (a) remove Discount from Sales_Mar if it is not needed, or (b) add a Discount column with default value 0 to Sales_Jan and Sales_Feb. We choose option (b) to preserve data. In Jan and Feb, add a custom column: = Table.AddColumn(PreviousStep, "Discount", each 0, type number). Now all three queries share the same five columns with identical types.
All three queries: [Date (date), Store (text), Product (text), Revenue (currency), Discount (number)].
5
Step 5 — Append as New QueryGo to Home → Append Queries → Append Queries as New. Choose "Three or more tables." Add Sales_Jan, Sales_Feb, and Sales_Mar to the list, then click OK. Power Query creates a new query with the step: = Table.Combine({Sales_Jan, Sales_Feb, Sales_Mar}). Rename this query to All_Sales.
Final query All_Sales contains all rows from three months with zero null values and consistent types.

Append vs. Merge — Strengths & Limitations

A common source of confusion in Power Query is distinguishing the Append operation from the Merge operation. In database terminology, append corresponds to a UNION (vertical concatenation of rows), while merge corresponds to a JOIN (horizontal combination of columns based on a key). Choosing the wrong operation is a surprisingly frequent error—analogous to confusing array concatenation with a hash-map lookup in code. The table below contrasts their behaviors across several dimensions.

Comparison of Append and Merge operations in Power Query
DimensionAppend (Union Rows)Merge (Join Columns)
DirectionVertical — adds rowsHorizontal — adds columns
SQL AnalogyUNION ALLLEFT JOIN / INNER JOIN
Key RequirementNo key needed; matches by column nameRequires one or more join key columns
Output Row CountSum of source row countsDepends on join type and key cardinality
Schema RequirementSame column names and types (ideally)At least one shared key column
Use CaseCombining monthly files, regional exports, or partitioned tablesEnriching a fact table with dimension attributes
KEY TAKEAWAY
If you think of a relational database as a library, an append is like adding more books to the same shelf (same category, same classification system), while a merge is like cross-referencing a book's ISBN against a separate catalog to attach metadata. The operations are orthogonal: you often need both in a single data pipeline—append to consolidate partitioned fact data, then merge to join in dimension attributes.
Limitation
Power Query's append does not deduplicate rows by default. If you need distinct rows (equivalent to SQL UNION without ALL), you must apply Remove Duplicates as a subsequent step after the append. Be mindful that Remove Duplicates can be computationally expensive on large datasets.

Connection to Advanced Theory — Dynamic Append & Folder Sources

The manual append workflow shown in this lesson is appropriate when the number of source tables is small and stable. In production environments, however, data engineers frequently need to append an unknown or growing number of files—such as daily CSV extracts dropped into a shared folder. Power Query addresses this via the Folder connector, which treats the entire contents of a directory as a single source and dynamically appends all files at refresh time. This is implemented internally using Folder.Files followed by a custom function that parses each file and a Table.Combine over the resulting list of tables.

Manual append vs. dynamic folder-based append
FeatureManual Append (This Lesson)Folder / Dynamic Append (Advanced)
Number of SourcesFixed and known at design timeVariable; new files auto-detected on refresh
M FunctionTable.Combine({Q1, Q2})Table.Combine(Table.AddColumn(Folder.Files(path), ...))
Schema RiskControllable — you inspect each queryHigher — a malformed file can break the pipeline
Schema EnforcementManual validation before appendUse Table.TransformColumnTypes and Table.SelectColumns in a reusable function

The folder-based approach essentially wraps everything covered in this lesson—column name normalization, type casting, and Table.Combine—inside a parameterized M function. Mastering the manual append covered here is a prerequisite: you need to understand what can go wrong with two tables before you can write robust code that handles hundreds.

Practice Problems

PROBLEM 1CONCEPTUAL
Explain in your own words why Power Query's Append Queries is analogous to SQL's UNION ALL rather than UNION. Under what circumstances would this distinction matter in a real dataset?
PROBLEM 2BASIC CALCULATION
You append three queries. Query_A has 1,200 rows and 6 columns, Query_B has 800 rows and 6 columns, and Query_C has 450 rows and 7 columns (the extra column is "Notes"). How many rows and columns does the resulting table have? How many null values are introduced in total?
PROBLEM 3INTERMEDIATE
You have two queries to append. Query_East has columns [OrderID, Customer, Amount, ShipDate] and Query_West has columns [OrderID, customer, amount, ShipDate]. Without making any changes, what does the appended result look like? Write the M code step that fixes Query_West's column names before the append.
PROBLEM 4APPLIED
A data engineering team receives daily CSV extracts from three regional warehouses. Each file has columns [Date, WarehouseID, SKU, Quantity, UnitPrice]. However, the Asia warehouse file uses a text-formatted date ("DD/MM/YYYY") while the others use the ISO 8601 date type. Describe a complete Power Query workflow to safely append these files monthly, including schema validation steps.
PROBLEM 5CRITICAL THINKING
Consider the relational algebra definition of union compatibility: two relations are union-compatible if they have the same degree (number of attributes) and the domain of each attribute in the first relation matches the domain of the corresponding attribute in the second. Does Power Query's Append enforce union compatibility in the strict relational sense? Argue whether this design choice is a feature or a deficiency, and propose a validation function in M that would enforce strict compatibility.

Lesson Summary

The Append Queries operation in Power Query performs a vertical union of rows from two or more tables, analogous to SQL's UNION ALL. The underlying M function Table.Combine takes a list of tables and produces a single output whose row count equals the sum of all inputs and whose column set is the set union of all column names. Crucially, columns are matched by exact name (case-sensitive), not by position.

Before appending, you must perform schema validation: verify that column names match exactly across all source tables, that data types are consistent, and that any extra or missing columns are handled deliberately—either by adding default-valued columns or removing unnecessary ones. Failure to validate schemas results in null-filled columns, duplicate column names from casing differences, or silent type promotions that cause downstream errors. Mastering this foundational append-and-validate workflow prepares you for advanced patterns such as dynamic folder-based appends and parameterized M functions that enforce schema contracts at scale.

Varsity Tutors • Microsoft Power BI • Appending Queries — Append queries (union rows) and validate schema alignment (intro)