Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
149 views
in Technique[技术] by (71.8m points)

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

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...