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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
amirabedhiafi
Impactful Individual
Impactful Individual

Find the No. of Customers that were there in the Last Year data as well as

I have a small data which has two tables in it. Sales table contains the two columns, Order Date, Customer Name, and Date Table contains the Date column with two years of data (2015 and 2016). 

I am being required to find the No. of Customers that were there in the Last Year data as well as in the Current Year data using DAX.

@amitchandak 

Amira Bedhiafi
Full Stack Business Intelligence Consultant @Capgemini
1 ACCEPTED SOLUTION

I read this as the number of customers, not the number of sales, therefore distinct count would be better.  

No of customers thisyear =
CALCULATE(DISTINCTCOUNT(sales[customer name]), 'Date'[Year] = YEAR(today()))

 

No of customers lastyear = CALCULATE(DISTINCTCOUNT(sales[customer name]), SAMEPERIODLASTYEAR'Date'[Date]')
 

View solution in original post

5 REPLIES 5
Pragati11
Super User
Super User

Hi @amirabedhiafi ,

 

You can do the following:

  1. Create a relationship between SALES and DATE table on OrderDate (Sales) and Date(Date) columns.
  2. Create a bar chart.
  3. Move YEAR part of Date(DATE) column in the x-axis and COUNT(CustomerName) in the y-axis.

This will give you number of customers by year - for both 2015 and 2016.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

What about using DAX?

Amira Bedhiafi
Full Stack Business Intelligence Consultant @Capgemini

Hi @amirabedhiafi ,

 

You can use following DAX:

ThisYearCount = CALCULATE(COUNT(Sales[CustomerName]), DATESYTD(Date[Date]))
LastYearCount = CALCULATE([ThisYearCount], SAMEPERIODLASTYEAR(Date[Date]))

 

Check if these work.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

I read this as the number of customers, not the number of sales, therefore distinct count would be better.  

No of customers thisyear =
CALCULATE(DISTINCTCOUNT(sales[customer name]), 'Date'[Year] = YEAR(today()))

 

No of customers lastyear = CALCULATE(DISTINCTCOUNT(sales[customer name]), SAMEPERIODLASTYEAR'Date'[Date]')
 

These are the choices, I am confused which one is correct : 

tempsnip.png

Amira Bedhiafi
Full Stack Business Intelligence Consultant @Capgemini

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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