How to Calculate New Customers Enrollments Using Power BI DAX Calculated Columns + Measure


In this article, we will walk through a practical example of using DAX in Power BI to calculate New Customers. Identifying when a customer makes their first purchase is crucial for businesses that want to analyze customer acquisition and growth over time.

This tutorial will guide you through the process using DAX-calculated columns and measures with examples and screenshots to make it easy to follow.

Overview of the Data Model

Our Power BI data model consists of three key tables:

  1. Sales – contains transactional data.

  2. Customers – includes customer-related information.

  3. Calendar – a date table used to slice the data by time.

Step 1: Calculating the First Purchase Date for Each Customer

The first step in identifying new customers is determining when each customer made their first purchase. To do this, we need to create a calculated column in the Customers table that tracks the First Purchase Date for each customer.

DAX Code to Calculate First Purchase Date:

FirstPurchaseDate = CALCULATE(MIN(Sales[OrderDate]))

Explanation:

  • MIN(Sales[OrderDate]): This returns the earliest OrderDate for each customer.

  • CALCULATE: Adjusts the context to evaluate the minimum order date for each customer.

Because there is already a relationship between the Sales and Customers tables, the calculation automatically determines the first transaction date per customer based on the CustomerKey.

Step 2: Flagging First Transactions in the Sales Table

Once we have the first purchase date, the next step is to flag transactions that represent the customer’s first purchase. This helps us distinguish between initial and repeat transactions in the Sales table.

DAX Code to Flag First Transactions:

Flag_FirstTransaction = RELATED(Customers[FirstPurchaseDate]) = Sales[OrderDate]

Explanation:

  • RELATED: This function brings the FirstPurchaseDate from the Customers table into the context of the Sales table.

  • This comparison checks whether the OrderDate in the Sales table matches the FirstPurchaseDate for the customer. If it does, the column returns True, marking that transaction as the customer’s first.

Step 3: Calculating the Number of New Customers

Now that we have flagged the first transactions, we can calculate the total number of New Customers for any time period using a DAX measure. This measure will count unique customer keys where the first transaction flag is True.

DAX Code to Calculate New Customers:

New_Customers = CALCULATE(
    DISTINCTCOUNT(Sales[CustomerKey]),
    Sales[Flag_FirstTransaction]
)

Explanation:

  • DISTINCTCOUNT(Sales[CustomerKey]): Counts the unique customer keys.

  • CALCULATE: Recalculates the distinct count, but only includes rows where Flag_FirstTransaction is True, which effectively counts only the new customers.

Note:

Since there is an existing relationship between Calendar[Date] and Sales[OrderDate], you don’t need to define another relationship for the calculation. This ensures that the measure works with the Calendar table for time-based analysis.

Final Visualization

You can now use this DAX measure in your Power BI report to create visualizations, such as a bar chart or line graph, to track the number of New Customers over time. By linking the measure to your Calendar table, you can easily filter or slice the data by specific time periods to gain more insights.


Conclusion

Using DAX in Power BI for calculating New Customers is a practical way to track business growth and customer acquisition trends. By following this approach, you can gain actionable insights into your customer base and make more informed decisions about your marketing and sales strategies.

The three steps we’ve covered — calculating the first purchase date, flagging first transactions, and counting new customers — are fundamental techniques in Power BI that can be extended to many other business metrics.

Did you find this article valuable?

Support BI Diaries© by becoming a sponsor. Any amount is appreciated!