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

Comparison of Customer ID using DAX

Hi everyone,

 

I need help in the following situation,

 

Data available - Customer ID (not unique values) , Reporting period - (either "Prior Period" or "Current Period")

(One customer ID can have both Prior Period and Current Period)

 

I need a 3rd column which is Type of Customer - 

 

1) If customer ID is available in Prior Period and Current Period then it is "Recurring Customer"

2) If customer ID is available in Prior Period and not in Current Period then it is "Removed Customer"

3) If customer ID is available in not Prior Period and in Current Period then it is "New Customer"

 

I need to calculate this column using Dax, Kindly help.

 

7 REPLIES 7
mh2587
Super User
Super User

https://www.daxpatterns.com/new-and-returning-customers/


Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



AilleryO
Memorable Member
Memorable Member

Hi,

 

I can do that but can you tell me what you need ? What is not working ?

Having a view of your model might help as well.

Customer Type =
var currentCustomer = 'ROT Revenue Subledger'[Customer ID]
var prevPeriod = FILTER( 'ROT Revenue Subledger', 'ROT Revenue Subledger'[Customer ID] = currentCustomer &&'ROT Revenue Subledger'[ROT - Reporting Period (Sorted)] = "Prior Period")
var currentPeriod = FILTER( 'ROT Revenue Subledger', 'ROT Revenue Subledger'[Customer ID] = currentCustomer && 'ROT Revenue Subledger'[ROT - Reporting Period (Sorted)] = "Current Period")
return SWITCH( TRUE(),
NOT(ISEMPTY(prevPeriod)) && NOT(ISEMPTY(currentPeriod)), "Recurring customer",
NOT(ISEMPTY(prevPeriod)) && ISEMPTY(currentPeriod), "Removed customer",
ISEMPTY(prevPeriod) && NOT(ISEMPTY(currentPeriod)), "New customer"
)
 
Could you check the following query ?

I tried this, but the values I am getting is New customer and blanks, could you kindly help me in understanding what went wrong here ?

Can you check your variable prevPeriod, because I think you're not getting anything from it.

AilleryO
Memorable Member
Memorable Member

Hi,

 

In case you haven't read that beautiful article from SQLBI, you should. It will answer your exact question 🙂

 

https://www.sqlbi.com/articles/computing-new-customers-in-dax/

 

Have a nice day and do not hesitate to share your solution.

Thankyou for the reply,

 

It seems like similar to my query, but could you help me in writing the DAX for my case ?

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors