Forum Discussion

kzmlbyrk's avatar
kzmlbyrk
Regular Visitor
3 years ago

identify lost customers using snapshotted data

Hello,

 

There are two monthly snapshotted tables as shared below.

I need to create a new column in the customers table.
This column needs to show whether or not the customer has zero active units left in that snapshot while at least one active contract in the previous snapshot.

 

In the example below, the customer with ID 10 was left with zero active contracts on snapshot 202203 while having 1 active contract on 202202; and was flagged as a lost customer on 202203.

 

CustomerIDYearMonth column is the key between the two tables.

 

Thanks in advance!

 

Contracts table

Snapshot Year MonthCustomer IDCustomerIDYearMonthContract IDIs Active Contract of This MonthIs Termination of This Month
20220110102022011TRUEFALSE
20220210102022021TRUEFALSE
20220310102022031FALSETRUE
20220410102022041FALSEFALSE
20220110102022012TRUEFALSE
20220210102022022FALSETRUE
20220310102022032FALSEFALSE
20220410102022042FALSEFALSE
20220120202022013TRUEFALSE
20220220202022023TRUEFALSE
20220320202022033TRUEFALSE
20220420202022043TRUEFALSE
20220120202022014TRUEFALSE
20220220202022024TRUEFALSE
20220320202022034TRUEFALSE
20220420202022044TRUEFALSE

 

Customers table 

Snapshot Year MonthCustomer IDCustomerIDYearMonthIs Lost Customer of This Month (Desired Result)
2022011010202201FALSE
2022021010202202FALSE
2022031010202203TRUE
2022041010202204FALSE
2022012020202201FALSE
2022022020202202FALSE
2022032020202203FALSE
2022042020202204FALSE

1 Reply