Forum Discussion

dsd_CS's avatar
dsd_CS
Frequent Visitor
8 years ago
Solved

Customer Churn and Retention Calculation - Dynamic range

Hi,

 

I am working on a customer retention calculation and need some help. My problem is related to calculating the denominator. To visualize the problem, I created the below dummy data in excel.

 

My definition of the retention rate measure (here: year 4)= All active customers in year 4 / all customers that had their first order at least 4 years ago.


So, according to the visualization, the sum of all yellow marked cells divided by the green marked cells.

 

Spoiler
 

 

In my Power BI file, I created calculated columns for "Customer lifetime (years)" and "time since first order (years)" on my distinct customer table.

The measure for retention denominator should be something like this:

I have the measure for the nominator, but struggle with the denominator. My current formula for the retention denominator measure looks like this:

 

Spoiler
Retention Denominator =
CALCULATE(
    DISTINCTCOUNT(Account[Account Id]),
FILTER(
    ALL(Account),
    Account[Time since first order YEAR] >= Account[Customer lifetime] && Account[Customer lifetime] >= 0
))

 
I get the same total for each column of customer lifetime (in a matrix visual). I am unable to filter based on customer lifetime.

How can I dynamically filter the values for "time since first order" based on the value of "customer lifetime"?

 

I'm fairly new to Power BI but included our two Power BI experts in-house and they didn't know how to solve it. I read through the forum, the examples on daxpatterns.com and in the book "the definitive guide to DAX". I have not implemented the "new vs. returning customers" pattern from daxpattern.com. 

Thank you for your help!

  • Hi dsd_CS,

     

    If I understand you correctly, the formula below should work in your scenario. :smileyhappy:

    Retention Denominator 2 = 
    CALCULATE(
        DISTINCTCOUNT('dummy data - customers'[customer ID]),
    FILTER(
        ALL('dummy data - customers'),
        'dummy data - customers'[Time since first order YEAR] >= MAX('dummy data - customers'[Customer lifetime])  && 'dummy data - customers'[Customer lifetime] >= 0
    ))

     

    Regards

9 Replies

  • v-ljerr-msft's avatar
    v-ljerr-msft
    Microsoft Employee

    Hi dsd_CS,

     

    Could you post your real table structure with some sample/mock data, so that we can better assist on this issue? It's even better that you can just share a sample pbix file. You can upload it to OneDrive or Dropbox and post the link here. Do mask sensitive data before uploading. :smileyhappy:

     

    Regards

    • dsd_CS's avatar
      dsd_CS
      Frequent Visitor

      Hi v-ljerr-msft,

       

      thank you for your reply. It's a very simple data model. I created some mock data to download here:

       

      https://tobii-my.sharepoint.com/:u:/p/dsd/EeI6VQJ4hFhDtT3v8baG5kIBB7hQcU_4d3e2LZfPrjYrvQ?e=WBrAnn


      I added a few visualizations to show the different steps. As you can see in visualization "Number of possible customers per lifetime year" my measure doesn't work. It shows the same number in every column. Whereas what I want is that it gives me a cumulative value where "time since first order" is greater or equal "customer lifetime" at lifetime 0.

       

       

      • v-ljerr-msft's avatar
        v-ljerr-msft
        Microsoft Employee

        Hi dsd_CS,

         

        If I understand you correctly, the formula below should work in your scenario. :smileyhappy:

        Retention Denominator 2 = 
        CALCULATE(
            DISTINCTCOUNT('dummy data - customers'[customer ID]),
        FILTER(
            ALL('dummy data - customers'),
            'dummy data - customers'[Time since first order YEAR] >= MAX('dummy data - customers'[Customer lifetime])  && 'dummy data - customers'[Customer lifetime] >= 0
        ))

         

        Regards