Forum Discussion

JavidRobatian's avatar
JavidRobatian
Frequent Visitor
2 years ago
Solved

DATEDIFF with condition

Hi experts, hope you all doing good. I have two tables in Power BI called Date and Invoice that are related with (invoice[date] 1:* Date[Date]) Now I'm trying to Calculate DateDiff with below condi...
  • Dangar332's avatar
    2 years ago

    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