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
- In the Query Editor, click Settings > Show Formula Bar or Hide Formula Bar.
Learn more about the Query Editor.
You can access the Query Editor from the Navigator pane when connecting to a data source, or at any time from the Workbook Queries pane or the contextual Query ribbon tab for an existing query. To learn how to load the Query Editor, see Power Query Quick Start.
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
- In the Applied Steps list in the Query Settings pane, choose the step you want to immediately precede the new step (formula). The Query Settings pane is part of the Query Editor. See Power Query Quick Start.
- Click the fx icon to the left of the formula bar. A new formula is created in the form = <nameOfTheStepToReference>. For example, = Production.WorkOrder.
- 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.")
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
- In the Applied Steps list in the Query Settings pane, right-click the step you want to edit.
- From the context menu select Edit Settings.
- In the dialog box, edit the formula.
Edit a formula in the formula bar
- In the Applied Steps list in the Query Settings pane, choose the step you want to edit.
- In the formula bar, locate and change the parameter values to the values you want.
- Click Refresh.
Top of Page