Note: This article has done its job, and will be retiring soon. To prevent "Page not found" woes, we're removing links we know about. If you've created links to this page, please remove them, and together we'll keep the web connected.
Note: Power Query is known as Get & Transform in Excel 2016. Information provided here applies to both. To learn more, see Get & Transform in Excel 2016.
Note: For a quick video on how to display Query Editor, see the end of this article.
All query transformations in Power Query 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 ribbon, select View > Show > 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.
-
Click Refresh.
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.
No comments:
Post a Comment