I have 2 tables:
A. Customer, dimension table, with customer key as primary key. Key fields include:
- Customer key,
- 1stPurchaseDate (Date)
B. Sales, fact table, with customer key as foreign key. Key fields include:
- Sales order date (Date),
- Customer key
I want to create a DAX to know the count of sales order per 1st purchase month (like Jul 2017), with sales(customer key) = customer (customer key), sales order date within 60 days since first purchase.
I can create it in calculated column in below:
=CALCULATE(COUNT(Sales[ProductKey]),FILTER(Sales,Sales[OrderDate]>Customers[DateFirstPurchase] && Sales[OrderDate] - Customers[DateFirstPurchase] <=60 && Sales[CustomerKey] = Customers[CustomerKey]))
But how can I do it in DAX (calculated field)?
Thanks a lot for your help!!