Creating Calculated Columns

Creating Calculated Columns in Power BI

Calculated columns in Power BI are used to add new data fields to your tables based on existing data. These columns allow you to perform row-by-row calculations that become part of your data model and can be used in visuals, filters, and further analysis.

What is a Calculated Column

A calculated column is a column that you create using a formula written in DAX (Data Analysis Expressions). Unlike measures, calculated columns are computed for each row in the table and stored in the data model.

When to Use Calculated Columns

  • When you need a new column derived from existing data for each row.
  • For creating categories, labels, or classifications.
  • When performing row-level operations like concatenating text or calculating age.
  • To simplify filtering and grouping in reports.

How to Create a Calculated Column

  1. Open Power BI Desktop.
  2. Go to Data View by clicking the table icon on the left pane.
  3. Select the table where you want to add the calculated column.
  4. Click on New Column in the Modeling tab of the Ribbon.
  5. Enter the DAX formula for your calculation. Example: FullName = Customers[FirstName] & ” ” & Customers[LastName]
  6. Press Enter. The new column will appear in your table and can now be used in visuals.

Common Examples of Calculated Columns

  • Concatenating Columns: Combine first and last names into a full name.
  • Simple Arithmetic: Calculate profit by subtracting cost from revenue.
  • Conditional Columns: Create categories based on values, e.g., SalesCategory = IF(Sales[Amount] > 1000, “High”, “Low”)
  • Date Calculations: Calculate age from a birthdate or extract month and year from a date column.

Best Practices

  • Use calculated columns for row-level calculations only; for aggregations, prefer measures.
  • Keep formulas simple and readable for better performance.
  • Avoid creating too many calculated columns, as they increase the size of the data model.
  • Test the column values to ensure the calculation logic is correct.

Conclusion

Calculated columns in Power BI provide a powerful way to enrich your data model with additional fields derived from existing data. They allow row-level calculations, categorization, and transformations that enhance your reporting and analysis capabilities.

Home ยป Power BI Fundamentals >Data Modeling Basics > Creating Calculated Columns