Appending Data


Append data means taking two or more data sets and combining them into one larger set.

  • refers to stacking additional rows from one data set onto another, provided both data sets have the same structure and columns
  • Think of it as adding more records to the bottom of an existing table, expanding it vertically
  • typically used when you have multiple files or data sets containing the same kind of information for different periods, regions, or sources, and you want to aggregate all the records into one continuous list
  • does not combine different fields or enrich the data by associating details from one set to another as joins do
    • it simply increases the number of rows
  • two kinds:
    • inline append
      • An append query that combines data sets until all are combined
    • intermediate append
      • An append query that creates a combined data set but also retains the separate data sets

A UNION script is used to combine multiple tables together in a single set.

  • gives the same outcome as the append option in PowerBI
SELECT ProductID, ProductName, SaleDate, QuantitySold, Revenue, '2018' AS SalesYear FROM Sales 2018
 
UNION
 
SELECT ProductID, ProductName, SaleDate, QuantitySold, Revenue, '2019' AS SalesYear FROM Sales2019
 
UNION
 
SELECT ProductID, ProductName, SaleDate, QuantitySold, Revenue, '2020' AS SalesYear FROM Sales2020