Power BI is one of the most powerful business intelligence tools, and adding a custom column allows users to perform calculations, transform data, and enhance reports dynamically. Whether you need to clean data, create calculated fields, or apply specific logic, custom columns play a crucial role.
In this guide, you will learn how to add a custom column in Power BI step by step, understand its benefits, and explore best practices.
π What is a Custom Column in Power BI?
A custom column in Power BI is a new column created by applying formulas, calculations, or logic on existing columns. It allows you to modify and enhance your dataset within the Power Query Editor before loading the data into Power BI reports.
Unlike calculated columns, which are created in the Data Model using DAX, custom columns are created using Power Query M Language and provide more flexibility in data transformation.
πΉ Steps to Add a Custom Column in Power BI
Step 1: Open Power Query Editor
- Open your Power BI .pbix file.
- Click on Transform Data from the Home tab.
- The Power Query Editor window will open.
Step 2: Add a New Custom Column
- In Power Query Editor, go to the Add Column tab.
- Click on Custom Column.
- A new Custom Column Editor window will appear.
Step 3: Write Your Formula
- In the New Column Name field, enter a name (e.g., “Total Sales”).
- In the Custom Column Formula box, enter your formula.Example: Calculate the Total Sales with a 10% tax rate:MCopyEdit
[Total Sales] = [Sales] + ([Sales] * 0.10)
- Ensure there are no errors (a green check mark will appear if the formula is valid).
- Click OK to create the column.
Step 4: Apply and Load the Data
- Click Close & Apply in the top-left corner.
- The new column will be available in your Power BI dataset for reporting.
π Common Use Cases for Custom Columns
Here are some real-world applications where custom columns help in Power BI reports:
1οΈβ£ Profit Calculation
If you have Sales and Cost columns, you can calculate Profit:
2οΈβ£ Conditional Logic for Discounts
If you want to apply a discount based on sales amount, use an IF condition.
(This gives a 10% discount if sales are above βΉ5000, otherwise a 5% discount.)
3οΈβ£ Date Formatting
Convert a full DateTime column to just the year
4οΈβ£ Creating Full Name from First and Last Name
π‘ Best Practices for Custom Columns in Power BI
βοΈ Use meaningful column names β Avoid generic names like “Column1”.
βοΈ Optimize performance β Avoid complex calculations that slow down processing.
βοΈ Use conditional logic wisely β Keep formulas simple and readable.
βοΈ Test before applying β Validate the formula to avoid data errors.
βοΈ Prefer M Language for data transformation β Use Power Query for preprocessing data.
π Custom Column vs. Calculated Column
Feature | Custom Column (Power Query) | Calculated Column (DAX) |
---|---|---|
Where Created | Power Query Editor | Data Model (DAX) |
Language Used | M Language | DAX (Data Analysis Expressions) |
Best For | Data cleaning, transformations | Report-level calculations |
Performance | Faster as it modifies the dataset | Slower as it processes in real-time |
π When to Use a Custom Column?
β
Before loading data β If you need to transform data before using it in Power BI.
β
For data formatting β Modifying text, numbers, or dates in a dataset.
β
For pre-calculated metrics β Avoiding unnecessary calculations in reports.
β
For merging or splitting columns β Creating structured data for visualization.
π Conclusion
Adding a custom column in Power BI enhances data transformation, improves data structure, and simplifies report building. By leveraging Power Query M Language, you can efficiently preprocess data before using it in your reports.
Now that you have learned how to add a custom column in Power BI, try implementing it in your projects and explore different transformations.