Database Reference
In-Depth Information
4. Click Done to close the Advanced Editor window.
5. In the Query Settings pane, change the name of the query in the Name input box.
Give your function a descriptive name — for example, FunctionProfit — as opposed to Query1.
6. On the Home tab of the Query Editor, click the Apply & Close button.
Power Query creates a seemingly useless table and adds the query to the Workbook Queries pane, as
shown in Figure 7-18. Unfortunately, there is no way to create a function without creating an associ-
ated table, so as worthless as the table seems, you can't delete it.
Figure 7-18: Your function is ready to use.
You can now use this function in other queries that contain revenue and cost fields. For example,
Figure 7-19 shows a query with a field called Sales Amount and a field called Equipment Cost. You
can use your newly created function to calculate profit using these two fields.
Figure 7-19: A table with Sales Amount and Equipment Cost fields.
Right-click any column header and select Insert Custom Column. In the Insert Custom Column dialog
box (see Figure 7-20), you can invoke your function by name, passing the Sales Amount and Equip-
ment Cost fields as parameters separated by a comma.
Search WWH ::




Custom Search