Forum Discussion

MM_NL's avatar
MM_NL
Frequent Visitor
8 years ago
Solved

Max slicer date as input for dateadd

I am trying to make a measure wich always calculates an average over the past 5 months, based on the max selected date in a slicer The problem i have is that the dateadd function doenst work with a ...
  • popov's avatar
    8 years ago

    Hello, MM_NL
    The Syntax of DATEADD function is

    DATEADD(<dates>,<number_of_intervals>,<interval>)
    <dates> is column, not scalar value. MAX
    (Period) isn't work. You must set column, if you need only one date, you can use construction something like this:
    DATEADD ( FILTER ( Table[Period], Table[Period] = MAX (Table[Period] ) ), .......)

  • MM_NL's avatar
    MM_NL
    8 years ago

    I solved it, by replacing the table input in the filter expression by lastdate() on the date column

     

    Old:

    DATEADD(FILTER(Period, Period[Datecolumn] = max(Period[Datecolumn]))

     

    New

    DATEADD(FILTER(LASTDATE(Period[Datecolumn]), Period[Datecolumn] = max(Period[Datecolumn]))

     

    this way the filter expression accepted a column input instead of whole table

     

    Thank you Popov!