What is a Custom Column in Power BI?
If you've spent any time working with data in Power BI, you've likely had this exact thought: "This data is great, but it's missing the one piece of information I actually need." You might have a sales table with quantity and price, but not total revenue. Or you have a first name and a last name, but you really need a "Full Name" column for your report. This is where creating a custom column becomes your new best friend. This article will walk you through exactly what a custom column is and show you two different ways to create one in Power BI.
What is a Custom Column in Power BI?
A custom column is a new column that you add to a table in your data model by creating a formula. Instead of being part of your original data source (like a spreadsheet or database), it's calculated and generated directly inside Power BI. Think of it as a way to enrich and transform your data on the fly to get it ready for analysis and visualization.
For a simple analogy, imagine an Excel sheet with two columns: Quantity (Column A) and Price per Item (Column B). To get the total cost for each row, you'd create a new column (Column C) and fill it with the formula =A2 * B2. That new column is essentially a custom column - it didn't exist in your original data, but you created it by combining existing information.
In Power BI, this concept is much more powerful. You can run simple math, combine text, apply conditional logic, and more to create the exact data field you need for your report.
Why Is Creating a Custom Column So Useful?
Beyond simple calculations, custom columns are fundamental to good data modeling and reporting. They are the workhorse of data preparation. Here are a few common scenarios where they are indispensable:
- Calculating New Metrics: This is the most common use. You can calculate profit (
[Sales] - [Cost]), shipping time ([ShipDate] - [OrderDate]), or revenue ([Quantity] * [Price]). These are vital KPIs that often don't exist in your source data. - Categorizing or "Bucketing" Data: You can create columns to segment your data. For example, you can create a
Deal Sizecolumn that labels transactions as "Small," "Medium," or "Large" based on the revenue amount. This is phenomenal for slicers and charts. - Combining Text Fields: A classic example is combining a
[FirstName]column and a[LastName]column to create a single[FullName]column. This cleans up your tables and makes your charts and reports more readable. - Cleaning and Standardizing Data: You can use custom columns to extract part of a text string (like a product ID from a long description), change the case of text (from "usa" to "USA"), or format dates into a more useful format, like just the month or day of the week.
Power Query vs. DAX: Two Paths to the Same Goal
In Power BI, there are two primary environments where you can create a custom column: the Power Query Editor (using the M language) and the Data Model view (using DAX). While they can often achieve the same result, they work differently and are suited for different tasks.
1. Custom Columns in Power Query (Using M)
The Power Query Editor is the data transformation engine in Power BI. Creating a custom column here happens before the data is loaded into your model. Each formula is applied row-by-row as the data is ingested and refreshed. The new column is then physically added to your table - it’s just as if it were part of the original data source.
Best for:
- Data cleaning and preparation tasks.
- Combining text fields, splitting columns, basic math.
- Creating columns that are static and won't need to change based on user interactions in the report.
- Situations where you want the calculation performed at data refresh time, not every time a filter is clicked.
2. Calculated Columns in the Data Model (Using DAX)
Once your data is loaded into the Power BI model, you can add "calculated columns" using DAX (Data Analysis Expressions). This is done from the Data view in the main Power BI window. Like in Power Query, DAX formulas are also calculated row-by-row. However, they have full access to the entire data model, meaning they can reference columns from other related tables.
Best for:
- Calculations that depend on relationships between tables (e.g., pulling a product category from a separate 'Products' table into your 'Sales' table).
- More complex business logic that requires functions not available in Power Query's M language.
General Rule of Thumb: If you can create the column in Power Query, it's often better to do so. It keeps your DAX model cleaner and can sometimes lead to better performance since the work is done during data refresh.
Step-by-Step: Adding a Custom Column with Power Query
Let’s walk through creating a Total Revenue column using a simple sales table. Imagine your data looks like this:
SalesData table: OrderID, ProductName, Quantity, Price
Step 1: Open the Power Query Editor
First, from the Home tab in the main Power BI ribbon, click on Transform data. This will open the Power Query Editor window where all the data shaping magic happens.
Step 2: Navigate to "Add Column"
In the Power Query Editor, select the SalesData table from the list on the left. Then, navigate to the Add Column tab in the ribbon at the top. Here, you'll see several options, including "Custom Column" and "Conditional Column."
Step 3: Create the Custom Column
Click on Custom Column. A new dialog box will appear.
- New column name: Type in a name for your column. Let's call it
Total Revenue. - Custom column formula: This is where you write your formula. You can either type the column names in directly (e.g.,
[Quantity]) or select them from the "Available columns" list on the right and click "Insert."
For our example, the formula is a simple multiplication:
=[Quantity] * [Price]
Make sure there are no syntax errors, then click OK. You'll instantly see your new Total Revenue column appear at the end of your table.
Bonus: Creating a Conditional Column
What if you want to classify sales based on a rule? The Conditional Column feature makes this easy without writing code.
Still in the Add Column tab, click Conditional Column. You can now build logic like an "IF...THEN...ELSE" statement.
- New column name:
Deal Size - IF... column
Total Revenueis greater than1000 - THEN... output
Large - Add Clause > ELSE IF... column
Total Revenueis greater than500 - THEN... output
Medium - ELSE... output
Small
Click OK, and you have a new category column that's perfect for quickly filtering your reports.
Step-by-Step: Adding a Calculated Column with DAX
Now let’s try creating the same Total Revenue column using DAX in the data model. Once you click "Close & Apply" in Power Query, your data loads into Power BI's model.
Step 1: Go to the Data View
In the main Power BI window, click on the Data icon in the vertical navigation bar on the far left. This shows you your tables in a spreadsheet-like view.
Step 2: Choose "New Column"
Make sure your SalesData table is selected in the Data pane on the right-hand side. The Table tools ribbon will appear at the top. Click on New column.
Step 3: Write the DAX Formula
A formula bar will appear above your table, just like in Excel. DAX syntax is slightly different from M in Power Query. Here’s how you’d write the same formula:
Total Revenue = SalesData[Quantity] * SalesData[Price]
In DAX, you typically preface a column name with its table name (e.g., TableName[ColumnName]). Press Enter, and your new calculated column will appear in the table.
Best Practices for Using Custom Columns
To keep your Power BI reports clean, fast, and easy to manage, follow these simple guidelines:
- Give Columns Descriptive Names:
MonthlyProfitis infinitely better thanColumn1. Someone else (or you, in six months) will thank you. - Do Transformations Early: Push as much of the data shaping and column creation as you can into the Power Query Editor. This keeps your data model cleaner and often improves performance.
- Check Your Data Types: After creating a custom column, especially in Power Query, make sure Power BI has assigned the correct data type (e.g., Whole Number, Decimal Number, Date). If it's wrong, your calculations and visualizations might fail.
- Avoid Overly Complex Columns: If your DAX formula for a custom column starts to look incredibly long and complex, you might be better served by creating a Measure. Measures are evaluated at report time and are better suited for aggregations and dynamic calculations that respond to user filters.
Final Thoughts
Mastering custom columns is a foundational step in truly unlocking the power of your data in Power BI. Whether you're doing basic data cleanup in Power Query or creating model-aware calculations with DAX, they provide the essential tools to shape your dataset so you can build meaningful and insightful reports that answer real business questions.
Of course, becoming proficient with Power Query and DAX takes time, and the entire process - connecting to data, cleaning it, and manually building visuals - is still a significant time investment week after week. At Graphed we decided there should be an easier way. We've built an AI data analyst that allows you to connect all your data sources and create dashboards simply by describing what you want to see. Instead of writing formulas to create columns, you can just ask, "Show me traffic from mobile vs. desktop for the last 30 days," and we build the visual for you, with the data always up-to-date.
Related Articles
How to Enable Data Analysis in Excel
Enable Excel's hidden data analysis tools with our step-by-step guide. Uncover trends, make forecasts, and turn raw numbers into actionable insights today!
What SEO Tools Work with Google Analytics?
Discover which SEO tools integrate seamlessly with Google Analytics to provide a comprehensive view of your site's performance. Optimize your SEO strategy now!
Looker Studio vs Metabase: Which BI Tool Actually Fits Your Team?
Looker Studio and Metabase both help you turn raw data into dashboards, but they take completely different approaches. This guide breaks down where each tool fits, what they are good at, and which one matches your actual workflow.