How to Create Calculated Column in Power BI: Step-by-Step Guide
To create a
calculated column in Power BI, go to the Data view, select your table, then click New Column on the ribbon. Write a DAX formula to define the column calculation, and Power BI will add it to your table as a new column.Syntax
The basic syntax to create a calculated column in Power BI is:
ColumnName = DAX_Expression
Here, ColumnName is the name you give to the new column, and DAX_Expression is the formula that calculates the column's values.
Calculated columns are added to tables and calculated row by row.
DAX
NewColumn = [ExistingColumn] + 10Example
This example creates a calculated column that adds 10 to the values in an existing column called Amount in the Sales table. It demonstrates how to add a simple calculation to each row.
DAX
Sales[SalesPlusTen] = Sales[Amount] + 10Output
If Sales[Amount] is 100, SalesPlusTen will be 110 for that row.
Common Pitfalls
Common mistakes when creating calculated columns include:
- Using measures instead of columns inside the formula, which causes errors.
- Forgetting that calculated columns are row-based, so aggregate functions like
SUMdon't work as expected. - Creating calculated columns on very large tables can slow down your report.
Always check that your formula references columns, not measures, and test with sample data.
DAX
Wrong: NewColumn = SUM(Sales[Amount]) + 10 Right: NewColumn = Sales[Amount] + 10
Quick Reference
| Step | Action |
|---|---|
| 1 | Go to Data view in Power BI Desktop |
| 2 | Select the table where you want the new column |
| 3 | Click 'New Column' on the ribbon |
| 4 | Enter your DAX formula for the calculated column |
| 5 | Press Enter to create the column |
Key Takeaways
Calculated columns are created using DAX formulas and added row by row to tables.
Always use column references inside calculated column formulas, not measures.
Create calculated columns in Data view by clicking 'New Column' and writing your formula.
Test your formulas with sample data to avoid common errors.
Calculated columns can impact performance on large datasets, so use them wisely.