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
Anonymous
Not applicable

DAX formula for customer life time

Hello,

 

I have an database as shown below. I am looking for a DAX formula which looks if a client is active in a certain year and is still a client in the next year. So if I choose a particular year I can see which clients have churned. 

 

I hope someone can help me with this one 🙂

 

Greetz Tiemen

 

 DB.PNG

1 ACCEPTED SOLUTION
v-haibl-msft
Employee
Employee

@Anonymous

 

I create a column with following formula. When you select a year in the slicer, the table will show the active customers in this year and show if this customer will churn in next year.

If it is not you wanted, please provide an expected output.

ChurnNextYear = 
IF (
    CONTAINS (
        Table1,
        Table1[Year as active client], Table1[Year as active client] + 1
    ),
    IF (
        ISBLANK (
            LOOKUPVALUE (
                Table1[Customer ID],
                Table1[Year as active client], Table1[Year as active client] + 1,
                Table1[Customer ID], Table1[Customer ID]
            )
        ),
        "Yes",
        "No"
    ),
    "Next year not exists"
)

DAX formula for customer life time_1.jpg

 

Best Regards,

Herbert

View solution in original post

7 REPLIES 7
v-haibl-msft
Employee
Employee

@Anonymous

 

I create a column with following formula. When you select a year in the slicer, the table will show the active customers in this year and show if this customer will churn in next year.

If it is not you wanted, please provide an expected output.

ChurnNextYear = 
IF (
    CONTAINS (
        Table1,
        Table1[Year as active client], Table1[Year as active client] + 1
    ),
    IF (
        ISBLANK (
            LOOKUPVALUE (
                Table1[Customer ID],
                Table1[Year as active client], Table1[Year as active client] + 1,
                Table1[Customer ID], Table1[Customer ID]
            )
        ),
        "Yes",
        "No"
    ),
    "Next year not exists"
)

DAX formula for customer life time_1.jpg

 

Best Regards,

Herbert

hi @v-haibl-msft  @CahabaData @ankitpatira 

Could you tell me how you calculated the column [Year as active client]? I meant if it is not available at the customer table how can we calculate it based on the purchases on Sales table?

Hi, What about if the column (Year as an Active client) is not available in the customer table but you have other information such as complete name, Address,....etc. On the other hand, the sales order table has a complete history of the customer purchases through the (customer Id) as a foreign key for a certain period of time, we need your help to show it through the sales table instead of the customer table, how can we archive this through DAX? 

Anonymous
Not applicable

Do you have an example of the data? Maybe i can help

Anonymous
Not applicable

@v-haibl-msft Thanks! this one does the trick 🙂 

CahabaData
Memorable Member
Memorable Member

well I might set up 2 calculated measure fields/columns:

 

Start Year = MIN of client Year value

 

Last Active Year = MAX of client Year value

 

that will result in a table visual where you can see each client, Start, Last Active

 

.... if you want to look by year as to what clients are active - then that is achieved with your current table and a slicer by year

 

..... or maybe you want to do a COUNT by year just to see how the annual totals change.... 

 

www.CahabaData.com
ankitpatira
Community Champion
Community Champion

@Anonymous if your end goal is to just analyse which customer has continued over years then i think easiest solution will be to use standard matrix visual and have years as rows and customer ids as columns with custid also as values.

 

Capture.JPG

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.