Forum Discussion
LY MTD Calculation
- 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
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