Forum Discussion
rajasekar_o
Helper V
1 year agoLY 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], ...
- Anonymous1 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 TeamIf 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
Kedar_Pande
Super User
1 year agoCorrected Measure:
LY MTD Sales =
VAR CurrentDate = MAX('date'[Date])
VAR PreviousYearStart = DATE(YEAR(CurrentDate)-1, MONTH(CurrentDate), 1)
VAR PreviousYearEnd = EOMONTH(PreviousYearStart, 0)
RETURN
CALCULATE(
[sales amount],
FILTER(
ALL('date'),
'date'[Date] >= PreviousYearStart &&
'date'[Date] <= PreviousYearEnd &&
'date'[Date] <= EDATE(CurrentDate, -12)
)
)