Customers who bought and not bought some product in last 90 days

烂漫一生 提交于 2019-12-13 08:10:52

问题


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:

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:


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.



来源:https://stackoverflow.com/questions/51968272/customers-who-bought-and-not-bought-some-product-in-last-90-days

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!