cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
cgoldstein Regular Visitor
Regular Visitor

Perform Calculation at Specified Level - Customer Churn

Hello!

 

I am new to DAX and looking for any assistance in writing a formula to calculate customer churn. I have one large fact table that contains all data required for this calculation (below).

 

There is more information available in the table then is needed to perform the calculation (i.e. there is a specific dimension that Churn needs to be calculated).

 

This is the dimension I would like to do the calculation:

@ the "Product Group_cd", "Location_Channel_cd", "AssignedSalesPersonName" level

Calculation being if one of the above purchased a unit this month, but did not last year in the same month, then "New Customer"

If one af the above purchased a unit last month py but not this month, the "Lost"

Otherwise "Retained"

 

Any help would be greatly appreciated! 

 

SalecCurrent.PNG

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Perform Calculation at Specified Level - Customer Churn

HI @cgoldstein ,

You can try to use following measure to check current row status:

Measure =
VAR currDate =
    MAX ( Table[Date] )
VAR LYDate =
    DATE ( YEAR ( currDate ) - 1, MONTH ( currDate ), DAY ( currDate ) )
VAR LYPurchased =
    CALCULATE (
        COUNTROWS ( Table ),
        FILTER (
            ALLSELECTED ( Table ),
            FORMAT ( Table[Date], "mm/yyyy" ) = FORMAT ( LYDate, "mm/yyyy" )
        ),
        VALUES ( Table[Product Group_cd] ),
        VALUES ( Table[Location_Channel_cd] ),
        VALUES ( Table[AssignedSalesPersonName] )
    )
VAR prevDate =
    CALCULATE (
        MAX ( Table[Date] ),
        FILTER ( ALLSELECTED ( Table ), [Date] < currDate ),
        VALUES ( Table[Product Group_cd] ),
        VALUES ( Table[Location_Channel_cd] ),
        VALUES ( Table[AssignedSalesPersonName] )
    )
RETURN
    IF (
        LYPurchased > 0,
        IF (
            FORMAT ( prevDate, "mm/yyyy" ) = FORMAT ( currDate, "mm/yyyy" ),
            "Retained",
            "Lost"
        ),
        "New Customer"
    )

If above not help, please share some sample data for test.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.



For learning resources/Release notes, please visit: | |

View solution in original post

2 REPLIES 2
Community Support Team
Community Support Team

Re: Perform Calculation at Specified Level - Customer Churn

HI @cgoldstein ,

You can try to use following measure to check current row status:

Measure =
VAR currDate =
    MAX ( Table[Date] )
VAR LYDate =
    DATE ( YEAR ( currDate ) - 1, MONTH ( currDate ), DAY ( currDate ) )
VAR LYPurchased =
    CALCULATE (
        COUNTROWS ( Table ),
        FILTER (
            ALLSELECTED ( Table ),
            FORMAT ( Table[Date], "mm/yyyy" ) = FORMAT ( LYDate, "mm/yyyy" )
        ),
        VALUES ( Table[Product Group_cd] ),
        VALUES ( Table[Location_Channel_cd] ),
        VALUES ( Table[AssignedSalesPersonName] )
    )
VAR prevDate =
    CALCULATE (
        MAX ( Table[Date] ),
        FILTER ( ALLSELECTED ( Table ), [Date] < currDate ),
        VALUES ( Table[Product Group_cd] ),
        VALUES ( Table[Location_Channel_cd] ),
        VALUES ( Table[AssignedSalesPersonName] )
    )
RETURN
    IF (
        LYPurchased > 0,
        IF (
            FORMAT ( prevDate, "mm/yyyy" ) = FORMAT ( currDate, "mm/yyyy" ),
            "Retained",
            "Lost"
        ),
        "New Customer"
    )

If above not help, please share some sample data for test.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.



For learning resources/Release notes, please visit: | |

View solution in original post

cgoldstein Regular Visitor
Regular Visitor

Re: Perform Calculation at Specified Level - Customer Churn

Is this possible if I do not have a date table? The table above is the only table I have imported into powerquery.

 

 

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 149 members 1,614 guests
Please welcome our newest community members: