Forum Discussion
AppleMan
2 years agoHelper III
Calculating Previous Sales Date
I have an interesting issue I need help figuring out. I have a table that is a list of orders (columns like order date, name, product, price, etc). I have been requested to create a measure tha...
- 2 years ago
I would suggest the following DAX measure:
New Customers - 3 Years =VAR N =CALCULATE(DISTINCTCOUNT(Orders[Customer ID]),FILTER (Orders,Orders[Order Date]= CALCULATE (MIN ( Orders[Order Date] ),ALLEXCEPT(Orders, Orders[Customer ID]))&&DATEDIFF(Orders[Order Date],TODAY(),YEAR)<3))VAR R = DISTINCTCOUNT(Orders[Customer ID])-NRETURNNSimply return 'R' for returning customers.
AppleMan
2 years agoHelper III
I did some testing, disregard this message I understand what it is doing now. I do not have a way to verify if the numbers I am getting are correct, but the code makes sense and I will accept this as the answer. I appreciate it!
I can open a new request if I find out the data I am getting is inaccurate and I need help refining it. Thanks again!
kb_cc
2 years agoFrequent Visitor
Try something like this:
New Customers =
CALCULATE(DISTINCTCOUNT(Orders[Customer ID]),
FILTER (
Orders,
NOT(Orders[Customer ID] IN VALUES(Customers[Customer ID]))
||
DATEDIFF(Orders[Order Date],TODAY(),YEAR)>3
)
)
The "pipes" (||) equate to an "or" in DAX.
Hope this helps!