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
Tanushree_Kapse
Impactful Individual
Impactful Individual

Calculate new customers for the month and respective sales

Hi All,

 

I need help in calculating the new customers for every month.

Below is the sample data:

CustNameMonthYearCashInvestmentsDeposit
AJan 2020102011
BJan 2020301312
AFeb 2020123012
BFeb 2020144510
CFeb 2020101220
DFeb 2020121415
EFeb 202023345

 

 

1. I need to calculate the distinct new customers count for the month and also the respective sum of cash, investment and deposit
For ex: From data: 
New customer for Jan:  2 ( A and B)
New customer for Feb: 3 ( C, D, E)


Expected result: 

MonthYearNewCustomersCashInvestmentsDeposit
Jan 20202403323
Feb 20203456040

 

 

Any help would be appreciated.

Thanks.



 

 

2 ACCEPTED SOLUTIONS

Tried this:
This is giving the values for respective month.
invNew =
VAR currentCustomers = VALUES(FACT_TABLE[CLIENTNAME])
VAR currentDate = MIN(DateSlicer[MONTH])

VAR pastCustomers = CALCULATETABLE(VALUES(FACT_TABLE[CLIENTNAME]),
ALL(DateSlicer[MONTH])
, DateSlicer[MONTH]<currentDate)

VAR newCustomers = EXCEPT(currentCustomers,pastCustomers)

RETURN SUMX(newCustomers, CALCULATE(SUM(FACT_TABLE[INVESTMENTS])))
 
 
Thanks @amitchandak , for your refrences, it helped a lot.

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

Hi @amitchandak ,
Yes, that helped. I am able to calculate the new customers using the below DAX: 


New Customers count=

var aMTD = calculate(sum(FACT_TABLE[INVESTMENTS]),datesmtd(DateSlicer[MONTH]))
var bLMTD = calculate(sum(FACT_TABLE[INVESTMENTS]),DATESMTD(DATEADD(DateSlicer[MONTH],-1,MONTH)))   
var newcust = sumx(VALUES(FACT_TABLE[CLIENTNAME]), if(ISBLANK(bLMTD) && not(ISBLANK(aMTD)) ,1,0))
return newcust
 
But, I also want to calculate the corredsponding Cash, Investments, deposits, made by these new customers for that month.
 
MonthYearNewCustomersCashInvestmentsDeposit
Jan 20202403323
Feb 20203456040

Can you please help.

@Tanushree_Kapse , In the last  measure do some change

 

example

new customer cash =

sumx(VALUES(FACT_TABLE[CLIENTNAME]), if(ISBLANK(bLMTD) && not(ISBLANK(aMTD)) ,[Cash],blank()))

 

 

new customer Deposit=

sumx(VALUES(FACT_TABLE[CLIENTNAME]), if(ISBLANK(bLMTD) && not(ISBLANK(aMTD)) ,[Deposit],blank()))

 

\Hi @amitchandak ,

 

New Investment=

Var currmonth= CALCULATE(DISTINCTCOUNT(FACT_TABLE[CLIENTNAME]),DATESMTD(DateSlicer[MONTH]))
Var prevmonth= CALCULATE(DISTINCTCOUNT(FACT_TABLE[CLIENTNAME]),DATESMTD(dateadd(DateSlicer[MONTH],-1,MONTH)))
return
sumx(VALUES(DateSlicer[MONTH]), if(ISBLANK(prevmonth) && not(ISBLANK(currmonth)) ,calculate(sum(FACT_TABLE[INVESTMENTS]),ALL(FACT_TABLE[CLIENTNAME])),Blank()))
 
 
I tried this, but it's just giving me the values for Jan 2020, for other months it is blank.

Tried this:
This is giving the values for respective month.
invNew =
VAR currentCustomers = VALUES(FACT_TABLE[CLIENTNAME])
VAR currentDate = MIN(DateSlicer[MONTH])

VAR pastCustomers = CALCULATETABLE(VALUES(FACT_TABLE[CLIENTNAME]),
ALL(DateSlicer[MONTH])
, DateSlicer[MONTH]<currentDate)

VAR newCustomers = EXCEPT(currentCustomers,pastCustomers)

RETURN SUMX(newCustomers, CALCULATE(SUM(FACT_TABLE[INVESTMENTS])))
 
 
Thanks @amitchandak , for your refrences, it helped a lot.

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.

Top Solution Authors