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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
m_aa
Advocate I
Advocate I

Count the number of repeated orders over last 6 months

HI all, 

 

I'm facing the problem with counting the number of repeating orders. 

The main problem is that if the same customer bought product few times in current month, all his purchases except the first one should also be considered as repeated. 

 

All I managed to do so far is to calculate how many orders are from those who bought anything in previous 5 months:

var datemin = DATEADD(STARTOFMONTH('Calendar'[Date]),-5,MONTH)
var datemax = DATEADD(startOFMONTH('Calendar'[Date]),-1,DAY)
var table1 = CALCULATETABLE(VALUES('Orders'[User_ID]),ALL('Orders'),DATESBETWEEN('Orders'[Date_payed],datemin,datemax))
var ordersrep = CALCULATE(DISTINCTCOUNT('Orders'[Order_ID]),YEAR('Orders'[Date_payed])=MAX('Calendar'[Year]),MONTH('Orders'[Date_payed])=MAX('Calendar'[Month]),'Orders'[User_ID] in (table1))
return
ordersrep

 

and repeated orders in current month:

var totalorders = CALCULATE(DISTINCTCOUNT('Orders'[Order_ID]),YEAR('Orders'[Date_payed])=MAX('Calendar'[Year]),MONTH('Orders'[Date_payed])=MAX('Calendar'[Month]))
var totalbuyers = CALCULATE(DISTINCTCOUNT('Orders'[User_ID]),YEAR('Orders'[Date_payed])=MAX('Calendar'[Year]),MONTH('Orders'[Date_payed])=MAX('Calendar'[Month]))
return
totalorders-totalbuyers

 

I can't just sum these two measures though as some orders are included in both. I think I should get the list, not the number, of each, unite it and return distinct count. Further I will need to calculate the sum of such orders But I failed to do so.

 

Any help?

2 REPLIES 2
v-jayw-msft
Community Support
Community Support

Hi @m_aa ,

 

Please share some sample data and expcted result so that you could test DAX formula.

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
amitchandak
Super User
Super User

@m_aa , There two ways of repeat - 1 is they purchased before duration or, they purchase twice

 

Purchased in last 6 months

Rolling 6 = CALCULATEDISTINCTCOUNT('Orders'[Order_ID]), DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-6,MONTH))

 

Repeat purchase customer =countx(Values(Customer[Customer]) , if([Rolling]>1, [Customer], blank())

 

in case it based on duration refer

 

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...

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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