Creating custom columns
Creating custom columns is a common data transformation activity when working with Power Query and the M language. While the number of scenarios for adding custom columns is effectively endless, a common example might be combining a unit price column and a quantity column into a single total sales
column. In this section, we will explore several ways to create custom columns both using the GUI of the Power Query Editor as well as writing custom M code.
Adding an index column
A common column added to M queries is an index column, which numbers the rows in sequential order. Index columns are extremely beneficial in certain scenarios, such as Mean Time Between Failure (MTBF), where it is necessary to compare the differences between two rows of data.
To add an index column to the existing query created in the Your First Query section of this chapter, do the following:
- Click on the Add Column tab of the ribbon, then click the drop-down arrow...