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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
MAAbdullah_47
Helper V
Helper V

Date Range calculation problems if the user select years Not consecutive

I have 2 Problems related to date Range:
Problem-1
I have measure (CLTV) that calculatetes customer life time value (CLTV) https://blog.hubspot.com/service/how-to-calculate-customer-lifetime-value
There is no problem in calculating the formula, but the challenge (CLTV) depends totally when selecting **(Two consecutive years)** otherwise it will not calculate correctly, My Question how to deal if the User select (2) Years that are Not consecutive from the Years Slicer By alerting the customer to correct his selection or to do condition in the formula to make the calculation(CLTV) only if the years
are consecutive?

Problem-2
I made a complete process to calculate customer customer segmentation through (RFM) https://en.wikipedia.org/wiki/RFM_(market_research)

For calculating the recency of the customer I have 1 measure(cstRecency) and 1 calculated column(Cust Recency) that do the same thing as it showed below:

Cust Recency = DATEDIFF([cstLastTrnDate], DATEVALUE("2018/11/16"), DAY)-->2018/11/16 (Last transaction date in sales oreder data)
cstLastTrnDate = CALCULATE(MAX(Sales[OrderDate]))
The transaction sales date range is from (1/1/2014) Up To (16/11/2018)
My Problem is in filtering the (recency) parameter range (1 to X) and/or selecting the year from slicer
for example :
-If I select the range from (1 to 365) it should filter the Customers segments whom recent visits in 2014 Only and , If I select (366-730) It should gives the customers whom visits (2014 and 2015) and so on.
How to reflect the (RFM) score dynamically based on the filter of the (recency)?

Note: I attached the (pbix) file, It is in Arabic But all the mentioned fields and formulas I make it in English in the Report Name (RFM).https://drive.google.com/file/d/1251v--r1h8B2Uglnv8jlxd1erDqHvhNm/view?usp=sharing 

3 REPLIES 3
AllisonKennedy
Super User
Super User

For problem 1 can you just have them select start year and then do calculation based on the selected year and previous year?

What result do you want the measure to give if more than 2 consecutive years are selected?

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Still the problem didn't solved.

@AllisonKennedy  Sorry I ddnt understand your point can you explain,
If I Understand Your Question The CLTV start calculating from after the first year, in our example after the year 2014, so if the user select 2014 the result will be 0 , After that the User should select single or more than one year but should be consecutive (successive) e.g. 2015,2017,2018 , If the user select 2015,2017 it will calculate but it will not reflect the real correct case.
You can look at the measure (CLTV) in the pbix file.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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