Forum Discussion

rajasekar_o's avatar
rajasekar_o
Helper V
1 year ago
Solved

LY MTD Calculation

Hi team, i want to calculate LYMTD Used Measure LY MTD Sales = VAR CurrentDate = MAX('date'[Date]) VAR PreviousYearDate = EDATE(CurrentDate, -12) RETURN CALCULATE(     [sales amount], ...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi, rajasekar_o 

    Thanks for Kedar_Pande, Greg_Deckler and bhanu_gautam replies. Are you currently addressing this issue? If not, you can refer to the following dax.

     

    LY MTD Sales = 
    VAR _currentDate = MAX('Table 2'[Inv Date])
    VAR _previousYearDate = EDATE(_currentDate, -12)
    VAR _item = SELECTEDVALUE('Table 2'[Item])
    RETURN
    CALCULATE(
        SUM('Table 2'[Amount]),
        FILTER(
            ALL('Table 2'),
            'Table 2'[Inv Date] <= _currentDate &&                  
            'Table 2'[Inv Date] >= _previousYearDate &&
            'Table 2'[Item] = _item
        )
    )
    

     

    Best Regards,
    Yang

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know.
    Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum