Forum Discussion
DATEDIFF with condition
- 2 years ago
Hi, JavidRobatian
try belowMeasure = var a = SELECTEDVALUE('date'[month]) var b = DATEDIFF(CALCULATE(min(invoice[date]),ALLEXCEPT(invoice,invoice[cu nu])),TODAY(),DAY) var c = DATEDIFF(CALCULATE(min(invoice[date]),ALLEXCEPT(invoice,invoice[cu nu])),DATE(2023,a,1),DAY) var d = IF(ISFILTERED('date'[month]),c,b) return d
Hi, JavidRobatian
try below
Measure =
var a = SELECTEDVALUE('date'[month])
var b = DATEDIFF(CALCULATE(min(invoice[date]),ALLEXCEPT(invoice,invoice[cu nu])),TODAY(),DAY)
var c = DATEDIFF(CALCULATE(min(invoice[date]),ALLEXCEPT(invoice,invoice[cu nu])),DATE(2023,a,1),DAY)
var d = IF(ISFILTERED('date'[month]),c,b)
return
d- JavidRobatian2 years agoFrequent Visitor
Thank you for your reply.
I tried this but its partly works.
I changed Min to Maxits work well when I not use slicer.
but I want when I choose 10 (in month slicer) Datediff equal to:
and when I choose 11 (in month slicer) Datediff equal to:
- Dangar3322 years agoResident Rockstar
HI, JavidRobatian
in your previous post DATEDIFF between DATE column and User SELECT Dateyou mention smallest number for each customer thats why i use min if you want latest date then you can use max()
with same formula select month(11) below result in imagewith same formula select month(10) below result in image
in above output is some diff in output
beacuse i am take your previous post data
- JavidRobatian2 years agoFrequent Visitor
Yes and thank you for your reply.
I don't know why it works for me like this.
I share my PBI file
https://drive.google.com/file/d/1MJ1vWk2BShxE87eH7BM7QYkBX03p8zY3/view?usp=drive_link