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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Dave_Gugg
Helper I
Helper I

DAX - Customer Rebuy/Gateway Analysis

I am trying to get a percentage of customers who rebuy based on the initial product purchased.  I have a standard fact/dimension data warehouse with a Order Placed fact, a Customer dimension, and a Product dimension.

I have set up the following custom metric in the demand table to get the number of customers whose first purchase included the selected product: 

First Purchase Customer Count = CALCULATE(DISTINCTCOUNT(Demand[CustomerKey]),Demand[Customer Order Sequence Number] = 1)

 Next I need a custom metric that will show the number of customers who purchased again.  This should only include those customers who purchased the item on their first order, but shouldn't be filtered based on the item(s) purchased in their second order.  The DAX I have attempted, but is not working is:

Rebuyer Count = CALCULATE(DISTINCTCOUNT(Demand[CustomerKey]),Demand[Customer Order Sequence Number] = 2,ALL('Product'[Item]),FILTER(SUMMARIZE(Demand,Demand[CustomerKey],[Customer Order Sequence Number]),[Customer Order Sequence Number] = 1))

Here is a screenshot of my table thus far:20170131 Gateway Analysis.PNG

 

Can someone please give me guidance in how to create that second formula?

 

Thank you

1 REPLY 1
Dave_Gugg
Helper I
Helper I

I was able to find a formula that gives me the correct answer, but it runs into the 1M row limit unless I filter on the product subcategory.  This is the formula:

Rebuyer Count = COUNTROWS(INTERSECT(SUMMARIZE(FILTER(Demand,Demand[Customer Order Sequence Number] = 1),[CustomerKey]),SUMMARIZE(CALCULATETABLE(FILTER(Demand,Demand[Customer Order Sequence Number] = 2),all('Product')),[CustomerKey])))

Can anyone help me refine this formula so it works for my full data set?

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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