Forum Discussion
Previous Year YTD, DAX help
- 7 years ago
Anonymous
Edited
YTD LY V2_B = VAR _Last = CALCULATE ( LASTNONBLANK ( Data[Date]; [YTD] ); ALL ( 'Date'[Date] ) ) VAR _LastVal = CALCULATE ( CALCULATE ( [YTD]; SAMEPERIODLASTYEAR ( 'Date'[Date] ) ); 'Date'[Date] = _Last ) RETURN IF ( SELECTEDVALUE ( 'Date'[Date] ) <= _Last; CALCULATE ( [YTD]; SAMEPERIODLASTYEAR ( 'Date'[Date] ) ); _LastVal )
YTD Prev Year = CALCULATE( [YTD], SAMEPERIODLASTYEAR('Date'[Date]))Hi Anonymous
Thanks for quick response i already tried something similar but problem is that like that i will have entire previous year shown,
and i want only to se PY YTD till last nonblank value of current year with this
'Date'[Date]<=LASTNONBLANK('Data'[Date],[Amount Sum])- Anonymous7 years agoNot applicable
I have also added few more months in date table. PBIX is available on same link
- AlB7 years ago
Community Champion
Hi Anonymous
This might be a quick and dirty solution:
YTD LY V2 = VAR _Last = CALCULATE ( LASTNONBLANK ( Data[Date]; [YTD] ); ALL ( 'Date'[Date] ) ) RETURN IF ( SELECTEDVALUE ( 'Date'[Date] ) <= _Last; CALCULATE ( [YTD]; SAMEPERIODLASTYEAR ( 'Date'[Date] ) ) )or this if you want to show the result only where [Amount PY] is non-blank
YTD LY V3 = VAR _Last = CALCULATE ( LASTNONBLANK ( Data[Date]; [YTD] ); ALL ( 'Date'[Date] ) ) RETURN IF ( SELECTEDVALUE ( 'Date'[Date] ) <= _Last && NOT ISBLANK ( [Amount PY] ); CALCULATE ( [YTD]; SAMEPERIODLASTYEAR ( 'Date'[Date] ) ) )- Anonymous7 years agoNot applicable
Thanks AlB
I fount this one lamost perfectly fitting my needs.
Is there maybe a way to fill other cell values with last YTD value (44 in thi case), like we have for normal YTD function.
So basically YTD PY would summ all PY values will last value of current day, and after that one it will just show lates value.