Customers who bought and not bought some product i

2019-09-20 00:20发布

I need a dax measure which shows me which customers bought products B and C in last 90 days.

And another one which shows me those whose bought products B and C in last 90 days.

(based in my filter date context)

Below is like it should be:

Image

Can someone help me?

Here is a sample data if needed:

FactSales

KeyDate KeyCustomer KeyProduct  Total
1   1   1   12,9
1   2   2   13
1   3   1   156,4
1   4   1   564,8
2   1   1   894,8
2   2   1   56,5
3   1   2   564,85
3   2   3   564,8
4   1   1   1325,6
4   2   1   132,3

Customer

KeyCustomer Name
1   Jean
2   Mari
3   Lisa
4   Julian
5   Jhonny

Calendar

KeyDate Date
1   01/01/2018
2   02/01/2018
3   01/05/2018
4   01/08/2018

Product

KeyProduct  Product
1   A
2   B
3   C

1条回答
Fickle 薄情
2楼-- · 2019-09-20 01:03

Try something along these lines:

IfBought = IF(
              COUNTROWS(
                  FILTER(FactSales,
                      RELATED('Product'[Product]) IN {"B", "C"} &&
                      RELATED('Calendar'[Date]) > TODAY() - 90)
                  ) > 0,
              1, 0)

Note that May 1st is longer than 90 days ago as of today though, so you won't get the result you asked for unless you change 90 to 114 or greater.

查看更多
登录 后发表回答