Forum Discussion

darlingling520's avatar
darlingling520
Regular Visitor
4 years ago
Solved

can't calculate DATEDIFF using Max function

Hi all,   I'm pretty new to power bi so I would like some help on this    I am trying to calculate the month difference between the max date and the selected date I tried 2 different methods: M...
  • Samarth_18's avatar
    4 years ago

    Hi darlingling520 ,

    You could try this:-

    datediff2 = 
    var max_date = calculate(max(DATA[date]),ALL(DATA[date]))
    return DATEDIFF(SELECTEDVALUE(DATA[date]),max_date,MONTH)

    BR,

    Samarth

  • darlingling520's avatar
    4 years ago

    okay I already figured out myself - in order to use the max function 

    i need to use maxdate= calculate(max(data[date]),all(data)); so the max date will be fixed and therefore i can use it to calculate the datediff