Modify a formula (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   For a very quick video on how to display Query Editor, see the end of this article.

All query transformations in Microsoft Power Query for Excel are performed by formulas. As you use the Query Editor builders, a formula is added to the formula bar. At times you may want to add a formula other than those associated with a builder, or you may want to alter an existing formula.

I want to

Show or hide the formula bar

Add formula to a query

Edit a formula

Edit a formula using the formula’s dialog box

Edit a formula in the formula bar

Show or hide the formula bar

  1. In the Query Editor ribbon, select View > Show > Formula Bar.

Show formula bar in Query Editor

Add formula to a query

You can find information on Power Query formulas at the Learn about Power Query formulas topic. When you create a 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.

Note    When you insert or delete an intermediate step in a query you might potentially break a query. Power Query will display an Insert Step warning when you try to insert a new step.

To add a formula to a query

  1. In the query step pane, select the step you want to immediately precede the new step (formula).

  2. Click the fx icon to the left of the formula bar. A new formula is created in the form = <nameOfTheStepToReference>. For example, = Production.WorkOrder.

  3. Type in the new formula using the format = Class.Function(ReferenceStep[,otherparameters]).
    For example, assume you have a table with the column Gender and you want to add a column with the value “Ms.” or “Mr.”, depending on the person’s gender. The formula would be = Table.AddColumn(<ReferencedStep>, "Prefix", each if [Gender] = "F" then "Ms." else "Mr.")

Example formula

Top of Page

Edit a formula

There are two ways to edit a formula: using the formula’s dialog box, and using the formula bar.

Edit a formula using the formula’s dialog box

  1. In the query step pane, right-click the step you want to edit.

  2. From the context menu select Edit Settings.

  3. In the dialog box, edit the formula.

Edit a formula in the formula bar

  1. In the query step pane, select the step you want to edit.

  2. In the formula bar, locate and change the parameter values to the values you want.

  3. Click Refresh.

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 2010, Excel 2013



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