Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Giorgi1989
Advocate II
Advocate II

Old vs new customer calculated column

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:  

 

  • If the customer has sales within last 12 months from the last purchase AND has no sales prior to that, then the customer is 'New'. 
  • If on the othe hand, the customer has sales both within last 12 months as well as months prior to that, then the customer is 'Old'. 

It seems to work fine for the last 12 months (From Sep 2023). But, then some months appear blank, which is not plausible. 

 

Giorgi1989_0-1696609367834.png

 

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. 

 

Customer Type =
VAR MAXMonth =
          MAX('Calendar'[date])
VAR Last12Months =
    DATESINPERIOD('Calendar'[date], MAXMonth,-12,MONTH)
VAR Last13to36Months =
    DATESINPERIOD(''Calendar'[date],Date(Year(MAXMonth)-1,Month(MAXMonth), Day(MAXMonth)),-24,MONTH)
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,
    "Repeat customer",
    "Old customer"
)
 
Anyone has an idea what might be wrong? Any inaccuracies in the DAX above, which I am simply overlooking?

Thank you for your help! 
2 REPLIES 2
Giorgi1989
Advocate II
Advocate II

Thank you, but that would not help! 

BeaBF
Super User
Super User

@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

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.