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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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