New vs returning customers in Power BI with DAX

How to split customers and revenue into new and returning for any period, the definition by first purchase date, new customer share, revenue from returning customers, reactivated customers, the DAX with a dynamic period, a stacked column chart, and common definition mistakes.

Short answer: in a period, a customer is new if their first purchase ever falls in that period, and returning if they bought in the period and had bought before it. Optionally split returning into active (bought in the last 12 months before) and reactivated (came back after a longer gap). Count customers and revenue in each group: a business growing only through new customers while returning revenue shrinks has a retention problem the total hides.

The split has to work for any period the reader picks: a month, a quarter, a custom range. That rules out a fixed "is new" column and calls for measures.

How does the split look?

  • New
  • Returning
  • Reactivated
02004006008001,000Q1Q2Q3
Revenue by customer type (k)
GroupCustomersRevenue (k)Revenue per customer
New2,480310125
Returning (active)3,170570180
Reactivated26030115
All5,910910154
Q3

Total revenue grows slightly each quarter, but returning revenue falls from 610 to 570: growth depends on ever more new customers.

What is the DAX?

Each customer's first purchase ever is CALCULATE ( MIN ( Sales[Date] ), ALL ( 'Date' ) ) evaluated for that customer. For the selected period:

Customers = DISTINCTCOUNT ( Sales[Customer ID] )

New Customers =
VAR PStart = MIN ( 'Date'[Date] )
VAR PEnd = MAX ( 'Date'[Date] )
RETURN
    COUNTROWS (
        FILTER (
            VALUES ( Sales[Customer ID] ),
            VAR F = CALCULATE ( MIN ( Sales[Date] ), ALL ( 'Date' ) )
            RETURN F >= PStart && F <= PEnd
        )
    )

Returning Customers = [Customers] - [New Customers]

New Customer Revenue =
VAR PStart = MIN ( 'Date'[Date] )
RETURN
    SUMX (
        VALUES ( Sales[Customer ID] ),
        IF ( CALCULATE ( MIN ( Sales[Date] ), ALL ( 'Date' ) ) >= PStart, [Revenue] )
    )

Returning Customer Revenue = [Revenue] - [New Customer Revenue]

New Customer Share = DIVIDE ( [New Customers], [Customers] )

Inside the iterator, CALCULATE turns the current customer ID into a filter (context transition) and ALL ( 'Date' ) removes the period, so it returns that customer's first purchase ever. A calculated column on the Customer table, First Purchase Date = CALCULATE ( MIN ( Sales[Date] ) ), is the faster alternative on large data. For reactivated customers, add a test that the customer had no purchase in the 365 days before PStart:

Reactivated Customers =
VAR PStart = MIN ( 'Date'[Date] )
RETURN
    COUNTROWS (
        FILTER (
            VALUES ( Sales[Customer ID] ),
            CALCULATE ( MIN ( Sales[Date] ), ALL ( 'Date' ) ) < PStart
                && ISEMPTY (
                    CALCULATETABLE ( Sales, DATESBETWEEN ( 'Date'[Date], PStart - 365, PStart - 1 ) )
                )
        )
    )

Which definitions must be settled?

  • What is "first purchase": the first order ever, or the first in this channel or brand?
  • Returns: does a customer whose only order was returned count?
  • Customer identity: guest checkouts and several accounts per person turn returning customers into new ones.
  • Reactivation gap: 12 months suits most shops; use the buying cycle.

What goes wrong?

  • A fixed "new" flag by calendar year. Breaks when the reader selects a quarter; compute per period.
  • New customers in a long period. In a full year, someone who first bought in January and again in June is "new" for the year; that is correct for the year, but surprising next to monthly numbers.
  • Data that starts late. If the history starts in 2024, every customer looks new in 2024; hide periods without a full look-back.

Where can you check this?

Where do you start?

Build New Customers and New Customer Revenue and show new and returning revenue as a stacked column chart by quarter. Customer acquisition cost puts a price on each new customer.

Keep reading

More from the blog.

Every post

Next

Building this? Say hello.

A question about this post, a pattern you would build differently, or the next thing you want written out: Behnia reads every message.