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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
mk5235
Frequent Visitor

Rolling L12 Months Calculated Column

Hello,

 

I have data structured in the columns below and also a calendar table:

 

Customer IDEOM DateMonthly Sales

 

I want to add L12 months sales and PY L12 months sales calculcated columns so I can create a rolling churn flag (if L12 is 75% or less of PY L12 then 1 else 0) then count the number of churned customers for any period. 

 

Can someone help with the most efficient formula to create the calculated columns? 

I keep seeing people say not to use calculated columns for this but not sure how I can get the count result without them so any help there would be appreciated as well.

 

Thanks!

1 ACCEPTED SOLUTION

Hi @mk5235 

 

You can create two calculated columns with below code. 

L12 Month Sales = SUMX(FILTER('Table','Table'[Customer ID]=EARLIER('Table'[Customer ID]) && 'Table'[EOM Date]<=EARLIER('Table'[EOM Date]) && 'Table'[EOM Date]>EDATE(EARLIER('Table'[EOM Date]),-12)),'Table'[Monthly Sales])
PY L12 Month Sales = SUMX(FILTER('Table','Table'[Customer ID]=EARLIER('Table'[Customer ID]) && 'Table'[EOM Date]<=EDATE(EARLIER('Table'[EOM Date]),-12) && 'Table'[EOM Date]>EDATE(EARLIER('Table'[EOM Date]),-24)),'Table'[Monthly Sales])

vjingzhang_0-1669110690956.png

 

If you want to count the number of churned customers for any month period, your idea with creating calculated columns is doable because your sales data is already in Month granularity. If the "Period" needs to be flexible e.g. count the number of churned customers for any month/quarter/year, using measures will be more flexible but the calculation speed may not be improved. 

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

3 REPLIES 3
v-jingzhang
Community Support
Community Support

Hi @mk5235 

 

What does "L12 months" mean? Since you have monthly sales data in the table, do you want to calculate the total sales of the past 12 months for every month row? For example, if a row has EOM Date 2022/9/30, you want to calculate the total sales with EOM dates from 2021/10/31 to 2022/9/30 for the same customer as "L12 months sales"? And then calculate totals sales from 2020/10/31 to 2021/9/30 as "PY 12 months sales"? Do I understand the requirement correctly?

 

Best Regards,
Community Support Team _ Jing

Hi - yes, thats exactly what I'm looking for!

Hi @mk5235 

 

You can create two calculated columns with below code. 

L12 Month Sales = SUMX(FILTER('Table','Table'[Customer ID]=EARLIER('Table'[Customer ID]) && 'Table'[EOM Date]<=EARLIER('Table'[EOM Date]) && 'Table'[EOM Date]>EDATE(EARLIER('Table'[EOM Date]),-12)),'Table'[Monthly Sales])
PY L12 Month Sales = SUMX(FILTER('Table','Table'[Customer ID]=EARLIER('Table'[Customer ID]) && 'Table'[EOM Date]<=EDATE(EARLIER('Table'[EOM Date]),-12) && 'Table'[EOM Date]>EDATE(EARLIER('Table'[EOM Date]),-24)),'Table'[Monthly Sales])

vjingzhang_0-1669110690956.png

 

If you want to count the number of churned customers for any month period, your idea with creating calculated columns is doable because your sales data is already in Month granularity. If the "Period" needs to be flexible e.g. count the number of churned customers for any month/quarter/year, using measures will be more flexible but the calculation speed may not be improved. 

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

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