Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Pinoo39
Frequent Visitor

New Customers DAX

Hi all,

 

I'm using "DaxPatterns"  article to calculate New Customers but couldnt find a way to filter some customers first. I need to filter Customers List based on an attribute (e.g. "Status" column in Sales Table) then use it in the formula.
I trid to define a variable like the following but it didn't work

VAR CustomersList =
CALCULATETABLE(VALUES(Sales[CustomerKey]), FILTER(Sales, Sales[type] in {7, 8} && Sales[status] in {4, 7}))
 

This is the Code :

 

Date New Customer :=
CALCULATE (                   -- The first sale is
    MIN ( Sales[Order Date] ), -- the MIN of the order date
    ALLEXCEPT (                 
        Sales,                -- ignoring any filter
        Sales[CustomerKey],   -- other than the customer
        Customer
    )
)

 

AND then number of New Customers is :

 

# New Customers :=
VAR CustomersWithNewDate =
    CALCULATETABLE (                       -- Prepares a table that
        ADDCOLUMNS (                       -- for each customer contains
            VALUES ( Sales[CustomerKey] ), -- the date of their first puchase
            "@NewCustomerDate", [Date New Customer]
        ),
        ALLEXCEPT ( Sales, Customer )
    )
VAR NewCustomers =
    FILTER (                              
        CustomersWithNewDate,              -- Filters the customers
        [@NewCustomerDate]                 -- whose new customer date
            IN VALUES ( 'Date'[Date] )     -- falls within the current period
    )
VAR Result =                               -- The count of the new customers
    COUNTROWS ( NewCustomers )             -- does not use the Sales table
RETURN
    Result


Any idea on doing that ?

6 REPLIES 6
amitchandak
Super User
Super User

@Pinoo39 , Try like, assuming a period is selected and the date table can give the dates for that period

 

This period =
var _min = minx(allselected('Date', 'Date'[Date]))
var _max = maxx(allselected('Date', 'Date'[Date]))
return
calculate([Sales], filter('Date', 'Date'[Date] >=_min && 'Date'[Date] <=_max) )


Last period =
var _min = minx(allselected('Date', 'Date'[Date]))
var _max = maxx(allselected('Date', 'Date'[Date]))
return
calculate([Sales], filter(all('Date'), 'Date'[Date] <_min) )

 

New Customer This period = sumx(VALUES(Customer[Customer Id]), if(ISBLANK([Last period]) && not(ISBLANK([This period])) ,1,BLANK()))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

MINX and MAXX require two arguments

amitchandak
Super User
Super User

@Pinoo39 , what is your defination of new

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

A customer is considered new if He/She has bought an item in the selected period on slicer (e.g. This month) and not in the past

amitchandak
Super User
Super User

@Pinoo39 , refer if my two blogs can help. You need change the duration for new (Last period )

Customer Retention Part 1:
https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-1-Month-on-Month-Retention/b...
Customer Retention Part 2: Period over Period Retention :https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-2-Period-over-Period-Retenti...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Since I'm using a DimDate Other than Gregorian DimDate, function like DatesMTD are not gonna work correctly

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.