Modify a formula
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.
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 query step pane, select the step you want to immediately precede the new step (formula).
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.")
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 query step 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 query step pane, select the step you want to edit.
In the formula bar, locate and change the parameter values to the values you want.