You can easily add a new custom column of data to your model using Query Editor in Power BI Desktop. You can create and rename your custom column using easy buttons to create M formulas that define your custom column.
Creating a custom column is another Applied Step to the query you create in Query Editor, which means it can be changed, moved earlier or later, or modified at any time.
To create a new custom column, launch Query Editor. You can do this by selecting Edit Queries from the Home ribbon in Power BI Desktop.
Once Query Editor is launched and you have some data loaded, you can add a custom column by selecting the Add Column tab on the ribbon, and then selecting Custom Column.
When you do so, the Add Custom Column window appears, which we discuss in the following section.
In the Add Custom Column window, you see the list of available fields in the pane on the right, the name of your custom column on the top (you can rename it just by typing a new name in that text box), and the M formula that you create (or write) based on inserting fields from the right, adding operators, and otherwise building the formula on which your new custom column will be defined.
You can select a field from the Available columns: list on the right, and select << Insert to add them to the custom column formula. You can simply double-click on a column in the list to add it, too.
As you type the formula and build your column, in the bottom of the window you'll see an indicator telling you, in real time (as you type) whether any syntax errors are detected. If all is good, you'll see a green checkmark.
But if you have some sort of error in your syntax, you get a yellow warning icon, along with the error detected, and a link that puts the cursor (in your formula) where the error is detected.
When you select OK, your custom column is added to the model, and the Added Custom step is added to your query's Applied Steps.
If you double-click the Added Custom step in the Applied Steps pane, the Add Custom Column window appears again, with the custom column formula you created already loaded, and ready for you to modify if necessary.
You can also create a custom column (and modify any step of your query, for that matter) using the Advanced Editor. In Query Editor select the View tab and then select Advanced Editor to display the Advanced Editor.
The Advanced Editor gives you full control over your query.
There are other ways to create a custom column, including creating a column based on examples you provide to Query Editor. See the following article for more information on creating custom columns from examples: