Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Measure using CALCULATE, FILTER and USERELATIONSHIP

Hello Community  -  The measure below works but with one important problem:   it is referencing the wrong date.  

 

In my salesorders table, we normally use "due date" and that is our primary connection to the date table.   I have an inactive relationship to the date table with "order date"  and that is the date I need to incorporate below.   I've tried placing USERELATIONSHIP into the measure but with no luck.    

 

We of course want to base our new customers on the date they placed an order, not the due date of the order.   And that is what this measure needs to do.  

 

New Customers = //calculating which customers within any particular month have purchased but haven't done so for the last X number of days
VAR _CustomersThisMonth = VALUES(SalesOrdersALL[CustNum_Cust_Seq_Orders])
VAR _PriorCustomers = CALCULATETABLE(VALUES(SalesOrdersALL[CustNum_Cust_Seq_Orders]),
FILTER(ALL('Dim_Date Table'),
'Dim_Date Table'[Date] > MIN('Dim_Date Table'[Date]) - [Churn Time Frame Value] &&
'Dim_Date Table'[Date] < MIN('Dim_Date Table'[Date])))

RETURN
COUNTROWS(EXCEPT(_CustomersThisMonth,_PriorCustomers))
  • You need to use CALCULATETABLE and USERELATIONSHIP for both your _CustomersThisMonth and _PriorCustomers variables.

3 Replies

  • You need to use CALCULATETABLE and USERELATIONSHIP for both your _CustomersThisMonth and _PriorCustomers variables.

  • julie_13579's avatar
    julie_13579
    Regular Visitor

    Formula works perfectly! Do you also have a formula for lost clients? 

    • lbendlin's avatar
      lbendlin
      Icon for Super User rankSuper User
      RETURN
      COUNTROWS(EXCEPT(_PriorCustomers,_CustomersThisMonth))