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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
shankarshiva
Frequent Visitor

Rolling customers repeat purchase check in current months- DAX

Hello Experts

I am trying to calculate repeat purchase customer count of rolling 12M customers in current month.

Like if we are in Dec22 then rolling customer 12month will be Dec21 to Nov22, if we are in Nov22 then rolling 12month customer will be Nov21 to Oct22.

I am tying to get this by below DAX but output is coming incorrect.

Need your help please.

 

Repeat in Current Month of Rolling L12M customers =
Var _enddate=MAX('Calendar'[Date])
var _startdate=EOMONTH(_enddate,-13)+1
VAR _Rolling12MCustomers =
    CALCULATETABLE('Secondary Data','Secondary Data'[New Key for Retailer count],FILTER(all('Calendar'),
         'Calendar'[Date]>=_StartDate&&'Calendar'[Date]<=EOMONTH(_enddate,-1)))
Var _CurrentMonthSales=
CALCULATETABLE('Secondary Data','Secondary Data'[New Key for Retailer count],
FILTER(all('Calendar'),MONTH('Calendar'[Date])=MONTH(MAX('Calendar'[Date]))&&YEAR(('Calendar'[Date])=YEAR(MAX('Calendar'[Date])))))
Var RepeatCustomers=INTERSECT(_CurrentMonthSales,_Rolling12MCustomers)
return
COUNTROWS(RepeatCustomers)
Thanks in advance
1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @shankarshiva ,

 

Based on your description, I have created a simple sample:

vjianbolimsft_0-1672992231355.png

vjianbolimsft_1-1672992242937.png

Please try:

Measure = 
var _a = EOMONTH(MAX('Calendar'[Date]),-1)
var _b = EOMONTH(MAX('Calendar'[Date]),-13)
var _c =SUMMARIZE('Table','Table'[Column],"Repeat",IF(NOT(ISBLANK(CALCULATE(COUNT('Table'[Column]),FILTER(ALL('Table'),[Date]<=_a&&[Date]>_b&&[Column]=EARLIER('Table'[Column]))))),1,0))
return SUMX(_c,[Repeat])

Final output:

vjianbolimsft_2-1672992273587.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
v-jianboli-msft
Community Support
Community Support

Hi @shankarshiva ,

 

Based on your description, I have created a simple sample:

vjianbolimsft_0-1672992231355.png

vjianbolimsft_1-1672992242937.png

Please try:

Measure = 
var _a = EOMONTH(MAX('Calendar'[Date]),-1)
var _b = EOMONTH(MAX('Calendar'[Date]),-13)
var _c =SUMMARIZE('Table','Table'[Column],"Repeat",IF(NOT(ISBLANK(CALCULATE(COUNT('Table'[Column]),FILTER(ALL('Table'),[Date]<=_a&&[Date]>_b&&[Column]=EARLIER('Table'[Column]))))),1,0))
return SUMX(_c,[Repeat])

Final output:

vjianbolimsft_2-1672992273587.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

shankarshiva
Frequent Visitor

Hello Experts

I am trying to calculate repeat purchase customer count of rolling 12M customers in current month.

Like if we are in Dec22 then rolling customer 12month will be Dec21 to Nov22, if we are in Nov22 then rolling 12month customer will be Nov21 to Oct22.

I am tying to get this by below DAX but output is coming incorrect.

Need your help please.

 

Repeat in Current Month of Rolling L12M customers =
Var _enddate=MAX('Calendar'[Date])
var _startdate=EOMONTH(_enddate,-13)+1
VAR _Rolling12MCustomers =
    CALCULATETABLE('Secondary Data','Secondary Data'[New Key for Retailer count],FILTER(all('Calendar'),
         'Calendar'[Date]>=_StartDate&&'Calendar'[Date]<=EOMONTH(_enddate,-1)))
Var _CurrentMonthSales=
CALCULATETABLE('Secondary Data','Secondary Data'[New Key for Retailer count],
FILTER(all('Calendar'),MONTH('Calendar'[Date])=MONTH(MAX('Calendar'[Date]))&&YEAR(('Calendar'[Date])=YEAR(MAX('Calendar'[Date])))))
Var RepeatCustomers=INTERSECT(_CurrentMonthSales,_Rolling12MCustomers)
return
COUNTROWS(RepeatCustomers)
Thanks in advance

@shankarshiva ,

Rolling 12 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-12,MONTH))

 

Rolling 12 before 12 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],eomonth(MAX('Date'[Date]),-12) ,-12,MONTH))

 

 

Lost Customer This Period = Sumx(VALUES(Customer[Customer Id]),if(ISBLANK([Rolling 12) && not(ISBLANK([Rolling 12 before 12])) , 1,BLANK()))
New Customer This Period = Sumx(VALUES(Customer[Customer Id]),if(ISBLANK([Rolling 12 before 12]) && not(ISBLANK([Rolling 12])) , 1,BLANK()))
Retained Customer This Period = Sumx(VALUES(Customer[Customer Id]),if(not(ISBLANK([Rolling 12])) && not(ISBLANK([Rolling 12 before 12])) , 1,BLANK()))

 

Customer Retention with Dynamic Segmentation, New/Lost/Retain Customer Count: https://www.youtube.com/watch?v=W4EF1f_k6iY

 

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

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
shankarshiva
Frequent Visitor

shankarshiva
Frequent Visitor

still waiting for response.

 

@administrator @pbiadmin @pbix @Admin 

amitchandak
Super User
Super User

@shankarshiva ,

Rolling 12 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-12,MONTH))

 

Rolling 12 before 12 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],eomonth(MAX('Date'[Date]),-12) ,-12,MONTH))

 

 

Lost Customer This Period = Sumx(VALUES(Customer[Customer Id]),if(ISBLANK([Rolling 12) && not(ISBLANK([Rolling 12 before 12])) , 1,BLANK()))
New Customer This Period = Sumx(VALUES(Customer[Customer Id]),if(ISBLANK([Rolling 12 before 12]) && not(ISBLANK([Rolling 12])) , 1,BLANK()))
Retained Customer This Period = Sumx(VALUES(Customer[Customer Id]),if(not(ISBLANK([Rolling 12])) && not(ISBLANK([Rolling 12 before 12])) , 1,BLANK()))

 

Customer Retention with Dynamic Segmentation, New/Lost/Retain Customer Count: https://www.youtube.com/watch?v=W4EF1f_k6iY

 

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

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi Amit,

 

Thanks for quick reply.

 

I don't want to check rolling customer 12 before 12. I want to check only rolling 12M customers repeat  in current month only. but as I am seeing you have taken 12 before 12 also which I think incorrect. 

 

Request you please help.

Thanks..

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.