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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
hananb
New Member

New costumers per day

 

Hi,

 

I tried to write a measure to find how many new customer we got in each day.

 

I created a mew table

 

First = SUMMARIZE(sales,Sales[Customer ID],"First Purchase",min(Sales[Purchase Date]))

 

I connected the "First Purchase" column, to the the date column in the calendar table, and with a measure:

 

Count New Client Alt. = COUNTROWS(First)

 

it's work.

 

But if I want to put all of them together:

 

Count New Client  = COUNTROWS(SUMMARIZE(sales,Sales[Customer ID],"First Purchase",min(Sales[Purchase Date])))

 

I got  a wrong answer, and I don't understand why (maybe because the lack of connection?).

 

Can someone explain it, and what is the right measure?

 

Thank you

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

@hananb

 

Have a look at the "new customers" patterns discussed on these pages:

https://www.sqlbi.com/articles/computing-new-customers-in-dax/

https://www.daxpatterns.com/new-and-returning-customers/

 

For example, I took the pattern discussed in the first link, and changed the column names to match your scenario (assuming you have a 'Calendar'[Date] column):

 

Count New Client =
COUNTROWS (
    FILTER (
        CALCULATETABLE (
            ADDCOLUMNS (
                VALUES ( Sales[Customer ID] ),
                "First Purchase", CALCULATE ( MIN ( Sales[Purchase Date] ) )
            ),
            ALL ( 'Calendar' )
        ),
        CONTAINS ( VALUES ( 'Calendar'[Date] ), 'Calendar'[Date], [First Purchase] )
    )
)

The only relationship required is between Sales[Purchase Date] and 'Calendar'[Date].

 

Does the above code or something from the above links work?

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

2 REPLIES 2
OwenAuger
Super User
Super User

@hananb

 

Have a look at the "new customers" patterns discussed on these pages:

https://www.sqlbi.com/articles/computing-new-customers-in-dax/

https://www.daxpatterns.com/new-and-returning-customers/

 

For example, I took the pattern discussed in the first link, and changed the column names to match your scenario (assuming you have a 'Calendar'[Date] column):

 

Count New Client =
COUNTROWS (
    FILTER (
        CALCULATETABLE (
            ADDCOLUMNS (
                VALUES ( Sales[Customer ID] ),
                "First Purchase", CALCULATE ( MIN ( Sales[Purchase Date] ) )
            ),
            ALL ( 'Calendar' )
        ),
        CONTAINS ( VALUES ( 'Calendar'[Date] ), 'Calendar'[Date], [First Purchase] )
    )
)

The only relationship required is between Sales[Purchase Date] and 'Calendar'[Date].

 

Does the above code or something from the above links work?

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Thank you,

 

it's work.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.