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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
ATO23
Frequent Visitor

Know how many users news repeat an order

Good morning everyone,

 

I'm facing a problem in my power BI model and I'm looking for some help.

 

I have a customer table where I have all the customer ID with every transaction (order) they made during a period. So I have one line per transaction. I also have a column to know if is the first time a customer is purchasing with a boolean of Y/N.

 

The problem I'm facing is that if I want to know the NEW customers I have in my table, I just need to do a calculate with a filter = Y in the column where I notice if it's the first purchase; however, I want to know how many times a NEW customer bought me in a filter date selection. 

For example, a customer buys for the first time in May 2023, and makes another purchase in July 2023. I want to know, that user is new and he did 2 purchases in that period.  If I apply a filter in the page to know all the users news, I miss that second purchase that have a N in the first purchase column, and I don't want to lose it. 

 

Any ideas?

 

Kind regards

 

 

1 ACCEPTED SOLUTION
EylesIT
Resolver II
Resolver II

@ATO23 , here is my suggested solution. Instead of a page-level filter, create the measures needed which do the filtering required.

 

I have used this set of test data:

 

CustomerIDorderIDperiodorder_valuenew_customer
C001O00101/05/20231234Y
C001O00201/07/20232345N
C002O00301/05/20233274Y
C003O00401/07/20232874Y
C004O00501/07/20232774N

 

Create a measure called [New Customers]:

 

 

 

New Customers = CALCULATE(DISTINCTCOUNT(YourTable[CustomerID]), YourTable[new_customer] = "Y")

 

 

 

Create a measure called [New Customer Orders]:

 

 

New Customer Orders = 
    VAR cust = SUMMARIZE(
        FILTER(YourTable, YourTable[new_customer] = "Y"),
        YourTable[CustomerID]
    )
    VAR orders = CALCULATE(
        COUNTROWS(YourTable),
        ALL(YourTable),
        YourTable[CustomerID] IN cust
    )
    
    RETURN orders
    

 

 

 

Add a slicer to your report, using the [period] field.

Add a Card visual to your report, and drag in the [New Customers] measure.

Add a Card visual to your report, and drag in the [New Customer Orders] measure.


This gives me the following results when May-23 is selected.

There are 2 new customers in May-23 (C001 and C002).

Of those two new customers, there are 3 total orders in the table (O001, 002 and O003).

 

EylesIT_2-1698176966562.png

 


This gives me the following results when Jul-23 is selected.

There is 1 new customers in Jul-23 (C003).

Of that new customer, there is 1 total orders in the table (O004).


EylesIT_1-1698176375898.png

 

Hope this helps.

View solution in original post

3 REPLIES 3
ATO23
Frequent Visitor

That works perfectly! Many thanks for your help!

EylesIT
Resolver II
Resolver II

@ATO23 , here is my suggested solution. Instead of a page-level filter, create the measures needed which do the filtering required.

 

I have used this set of test data:

 

CustomerIDorderIDperiodorder_valuenew_customer
C001O00101/05/20231234Y
C001O00201/07/20232345N
C002O00301/05/20233274Y
C003O00401/07/20232874Y
C004O00501/07/20232774N

 

Create a measure called [New Customers]:

 

 

 

New Customers = CALCULATE(DISTINCTCOUNT(YourTable[CustomerID]), YourTable[new_customer] = "Y")

 

 

 

Create a measure called [New Customer Orders]:

 

 

New Customer Orders = 
    VAR cust = SUMMARIZE(
        FILTER(YourTable, YourTable[new_customer] = "Y"),
        YourTable[CustomerID]
    )
    VAR orders = CALCULATE(
        COUNTROWS(YourTable),
        ALL(YourTable),
        YourTable[CustomerID] IN cust
    )
    
    RETURN orders
    

 

 

 

Add a slicer to your report, using the [period] field.

Add a Card visual to your report, and drag in the [New Customers] measure.

Add a Card visual to your report, and drag in the [New Customer Orders] measure.


This gives me the following results when May-23 is selected.

There are 2 new customers in May-23 (C001 and C002).

Of those two new customers, there are 3 total orders in the table (O001, 002 and O003).

 

EylesIT_2-1698176966562.png

 


This gives me the following results when Jul-23 is selected.

There is 1 new customers in Jul-23 (C003).

Of that new customer, there is 1 total orders in the table (O004).


EylesIT_1-1698176375898.png

 

Hope this helps.

some_bih
Super User
Super User

Hi @ATO23 check content on the link for start

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





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.