I have a table with customer records. When changes occur to records, the old one is kept and 'closed out' by updating end_Dt
and Current_Flag
, then a new record is added with the appropriate changes.
See example below:
Cust_ID | Name | Age | Phone type | Start_Dt | End_Dt | Current_Flag |
---|---|---|---|---|---|---|
12345 | Bob | 8 | apple | 12/02/22 | 01/15/23 | N |
12345 | Bob | 12 | Samsung | 01/16/22 | 12/31/99 | Y |
65739 | John | 44 | Samsung | 02/10/22 | 03/01/22 | N |
65739 | John | 44 | 03/02/22 | 12/31/99 | Y |
I'm developing a Change Report and need help creating a change column. Hoping the report would look like:
Cust_ID | Name | Change field |
---|---|---|
12345 | Bob | Age, Phone type |
65739 | John | Phone type |
I'm trying to accomplish this with SQL, or in Tableau Prep / Prep Builder.
I've tried to create flags variables for all fields, but have not had success with this effort. I've also tried a few CASE statements but have not had success.