The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi,
I am trying to create a calculated column that will consist of two options: 'Old' or 'New customer', based on certain crtieria, which I will provide below:
It seems to work fine for the last 12 months (From Sep 2023). But, then some months appear blank, which is not plausible.
Please, see my DAX below. I have been brainstorming for quite some time, what might be the reason behind the blank values in that simple matrix above.
The sales table has the data of about 5 years in it.
Thank you, but that would not help!
@Giorgi1989 Hi! I'va adjusted the code:
Customer Type =
VAR MAXMonth = MAX('Calendar'[date])
VAR Last12Months = DATESINPERIOD('Calendar'[date], MAXMonth, -12, MONTH)
VAR Last13to36Months = DATESBETWEEN('Calendar'[date], DATE(YEAR(MAXMonth) - 3, MONTH(MAXMonth), DAY(MAXMonth)), DATE(YEAR(MAXMonth) - 1, MONTH(MAXMonth), DAY(MAXMonth)))
RETURN
IF (
COUNTROWS (
FILTER (
'Sales',
'Sales'[Customer] = EARLIER('Sales'[Customer])
&& 'Calendar'[date] IN Last13to36Months
)
) > 0
&& COUNTROWS (
FILTER (
'Sales',
'Sales'[Customer] = EARLIER('Sales'[Customer])
&& 'Calendar'[date] IN Last12Months
)
) > 0,
"Old customer",
"New customer"
)
BBF
User | Count |
---|---|
25 | |
10 | |
8 | |
6 | |
5 |
User | Count |
---|---|
31 | |
11 | |
10 | |
10 | |
9 |