Growth percentages from previous days
This page adds a column that shows the percentage change in sales from one day to the next. The technique is to work out each row’s previous date, and then merge the query with itself to bring the previous day’s sales onto the same row.
The example starts from this Excel table of daily sales.

1. Add the previous date
Section titled “1. Add the previous date”- Click inside the table, and on Excel’s Data tab click From Table/Range. The Power Query Editor opens with a new query.
Data from an Excel table does not always arrive with a date type, so set it explicitly.
- Select the Date column, and set its data type to Date from the Data Type list.
Next, add a column that holds the day before each date.
- On the Add Column tab, click Custom Column.
- Type PreviousDate as the new column name, and enter this formula, which subtracts a duration of one day from the date:
= [Date] - #duration(1,0,0,0)![The Custom Column dialog with the new column named PreviousDate and the formula = [Date] - #duration(1,0,0,0)](/_astro/growth-percentages-2.C-UH9pNm_Z10Cbyo.webp)
- Click OK. The table now has a PreviousDate column beside each date.

2. Merge the query with itself
Section titled “2. Merge the query with itself”The previous day’s sales are in the same table, on another row. Merging the query with itself, matching PreviousDate to Date, brings them onto the current row.
- On the Home tab, click Merge Queries. The Merge dialog opens with the current query in the upper half.
- In the list for the second table, choose the current query again, which is marked (Current). In this example it is called PercentageGrowthPrevDayInput.
- Select PreviousDate in the upper table and Date in the lower table, leave the join kind as Left Outer, and click OK.

The merge adds a column of tables, named Added Custom after the step it merged with.

3. Calculate the growth
Section titled “3. Calculate the growth”- Click the expand icon in the Added Custom column header, clear every tick except Sales, and click OK.

A new column called Sales.1 shows the sales for the date in PreviousDate.
- Double-click the Sales.1 header and rename it PreviousDateSales.
The first date has no previous day in the table, so its PreviousDateSales is null. The merge also changes the order of the rows, which is put right later.

The query now holds both figures that the growth calculation needs.
- On the Add Column tab, click Custom Column again.
- Name the column PercentageSalesGrowth, and enter this formula:
= ([Sales] - [PreviousDateSales]) / [PreviousDateSales]
- Click OK. The new column holds each day’s growth as a decimal fraction.
- Select the PreviousDate and PreviousDateSales columns, right-click and choose Remove Columns.
- Select the Date column, and on the Home tab click Sort Ascending to put the rows back in date order.

- Click Close & Load.
- In the worksheet, format the PercentageSalesGrowth column as a percentage, by selecting the column, right-clicking and choosing Format Cells.

4. The M code
Section titled “4. The M code”let //Load data from Excel workbook Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], //Set the type of the Date column to be date #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Sales", Int64.Type}}), //Calculate the date one day before the current date #"Added Custom" = Table.AddColumn(#"Changed Type", "PreviousDate", each [Date] - #duration(1,0,0,0)), //Join the table to itself to look up the previous date value #"Merged Queries" = Table.NestedJoin(#"Added Custom", {"PreviousDate"}, #"Added Custom", {"Date"}, "Added Custom", JoinKind.LeftOuter), //Expand the Sales column from the joined table #"Expanded Added Custom" = Table.ExpandTableColumn(#"Merged Queries", "Added Custom", {"Sales"}, {"Sales.1"}), //Rename the new column to PreviousDateSales #"Renamed Columns" = Table.RenameColumns(#"Expanded Added Custom",{{"Sales.1", "PreviousDateSales"}}), //Calculate the percentage growth #"Added Custom1" = Table.AddColumn(#"Renamed Columns", "PercentageSalesGrowth", each ([Sales] - [PreviousDateSales]) / [PreviousDateSales]), //Remove the PreviousDate and PreviousDateSales columns #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"PreviousDate", "PreviousDateSales"}), //Sort the table in ascending order by the Date column #"Sorted Rows" = Table.Sort(#"Removed Columns",{{"Date", Order.Ascending}})in #"Sorted Rows"This example follows one in Chris Webb’s Power Query for Power BI and Excel (Apress).