Reputation: 3
I have 2 tables.
A. Customer table. Key column include 1. Customer ID (primary key) and 2. First Date purchase (in Date field) and 3. First purchase Date Year & Month (in text, like Jul 01).
B. Sales table. Key column include 1. Customer ID (foreign key) and 2. Sales order date (in Date field).
Both tables was in 1-many relationship. I want to find out how many customer return within 60 days since their first purchase, group by First purchase Date Year & Month. For example,
I will then perform calculation in pivot table for % of return customer per first purchase month, like below.
My desire result was a pivot table in below: enter image description here
But as Sales had quite a large volumn, and it's not a best practice to use Filter in this case. Therefore, can this be achieve by either:
It's highly appreciated for yours' help. Thanks.
Upvotes: 0
Views: 1738
Reputation: 3741
If you have a relationship in a model then you don't need a Sales[CustomerKey] = Customers[CustomerKey]; Try to use this calculation (not tested).
MeasureToCount = CALCULATE (
COUNTROWS (
CALCULATETABLE (
VALUES(Sales[CustomerKey]),
FILTER (
Sales,
Sales[SalesOrderDate] > RELATED(Customer[FirstPurchase])
&& (Sales[SalesOrderDate]) <= ( RELATED(Customer[FirstPurchase]) + 60 )
)
)
)
)
Now if you add "Year & Month" to Table visualization with measure, that should work.
Upvotes: 0