Forum Discussion
Dax
Hi Everyone,
I have two tables Sales & Calendar. Sales contain columns 'customerName', 'salesDate', and 'productAmount'. While the calendar contains all the dates.
I have created a new column named 'customerType' (Using DAX). I categorize Customers as 'New', 'Active', 'Inactive', and 'Lost'.
The definition of these is:
- New: Customer who has done first purchase
- Active: After 1st purchase all the other purchases have been done by the customer.
- Inactive: If the customer has not made any purchases after 30 days of 'Active' status until the next 'Active' status comes.
- Lost: If the customer has not made purchases for 60 days.
I have done this by creating a measure on that newly created column.
(Spanish to English)
Table:
Ventas = Sales
Column
fecha = date,
Cliente = Client/Customer
The Below image is of Newly Created Column
Measure is
I have also created another measure to get the count of active/New/Inactive/Lost Customers.
Now the problem is that when I go to get the Lost customer the count of the Data is Incorrect.
The first three columns from the Calender table and all others the measured from the 'Sales' table.
Note that the joining condition between 'Sales' and 'Calendar' is date and Calender contains all the Dates but Sales contains date where the data is available.
1 Reply
- amitchandakSuper User
Anonymous , Please find the example in the file . In case you need to count or filter please follow dynamic segmentation in the video
File after signature
New active = var _count = countrows(Sales)+ 0 var _diff =Datediff(CALCULATE(Max(Sales[Sales Date]), Filter(ALL('Date'), 'Date'[Date] <= Max('Date'[Date]))), Max('Date'[Date]), day) return Switch( True(), Max('Date'[Date]) = Max(Sales[Sales Date]) , "Active", Max('Date'[Date]) < Minx(ALLEXCEPT(Sales,Customer[Name]), Sales[Sales Date]), blank(), Max('Date'[Date]) = Minx(ALLEXCEPT(Sales,Customer[Name]), Sales[Sales Date]), "New", _diff<=30 , "Inctive", _diff >60 , "Lost", "Partially Lost")Customer Retention with Dynamic Segmentation, New/Lost/Retain Customer Count: https://youtu.be/EyL7KMw877Q