Insert a custom column into a table (Power Query)

Important   This article applies to Power Query, a data analysis feature available for Excel that lets you discover, combine and refine data. You may need to enable Power Query in Excel. You can also download and install the most recent version of Power Query for Excel, which automatically enables it. Power Query technology is also built into the Power BI Designer, which is a stand-alone report authoring and data transformation tool for Power BI.

Note   The Query Editor only appears when you load, edit, or create a new query using Power Query. For a very quick video on how to display Query Editor, see the end of this article.

With Microsoft Power Query for Excel, you can add an Index or Custom (you define the formula) column to your current query. When you create a column formula, Power Query will validate the formula syntax. This validation experience is consistent with how the Advanced Query Editing dialog validates formulas provided by you.

I want to

Insert an Index Column

Insert a Custom Column

Insert an Index Column

Using the Query Editor ribbon

  1. In the Query Editor ribbon, click Insert Index Column.

Using the table icon (Table icon) in the preview grid

  1. Click the table icon (Table icon).

  2. From the context menu, select Insert Index Column. An Index column is added in the query table. Rename the column name as required.

Top of Page

Insert a Custom Column

A custom column is a column where the value in a cell is computed using a formula that you create. For more information about the Power Query Formula Language, see Learn about Power Query formulas.

Using the Query Editor ribbon

  1. In the Query Editor ribbon, click Insert Custom Column.

Using the table icon (Table icon) in the preview grid

  1. Click the table icon (Table icon), and click Insert Custom Column.

To insert a custom column

  1. In the Insert Custom Column dialog box, enter a column name, and insert a column into the Custom Column Formula box:

    1. Double click a column from the Available Columns list or

    2. Click a column from the Available Columns list, and click Insert.

      Note    You can use multiple reference columns as long as you separate them with some operator. For example, to calculate a TotalSales column, you add Total and SalesTax using the formula = each [Total] + [SalesTax].

  2. Click OK.

Example formulas

Formula

Description

"abc"

Creates a column with the text abc in all rows.

1+1

Creates a column with the result of 1 + 1 (2) in all rows.

[UnitPrice] * [Quantity]

Creates a column with the result of multiplying two table columns.

[UnitPrice] * (1 – [Discount]) * [Quantity]

Calculates the total price, considering the Discount column.

"Hello" & [Name]

Combines Hello with the contents of the Name column in a new column.

Note    You can use custom column to merge values from two or more columns into a single custom column. For more information, see Merge columns.

With Power Query, Custom Columns, conditional formatting in Excel, and other customizations of worksheet tables are preserved after you refresh a query. Power Query will preserve worksheet customizations such as Data Bars, Color Scales, Icon Sets or other value-based rules across refresh operations and after query edits.

Custom Columns

Top of Page

Note   The Query Editor only appears when you load, edit, or create a new query using Power Query. The following video shows the Query Editor window appearing after editing a query from an Excel workbook. To view the Query Editor without loading or editing an existing workbook query, from the Get External Data section in the Power Query ribbon tab, select From Other Sources > Blank Query. The following video shows one way to display the Query Editor.

How to see Query Editor in Excel

Applies To: Excel 2013, Excel 2010



Was this information helpful?

Yes No

How can we improve it?

255 characters remaining

To protect your privacy, please do not include contact information in your feedback. Review our privacy policy.

Thank you for your feedback!

Support resources

Change language