By the way, to make script more universal (to calculate properly in case of multiple periods within one year) look on this (using property TIMEID):
*SELECT(%YS%,[YEAR],TIME,ID=%TIME_SET%)
*SELECT(%TY%,[ID],TIME,YEAR=%YS% AND PERIOD=JAN)
*SELECT(%Y%,[YEAR],TIME,ID=%TY%) //Single Year in %Y%
*SELECT(%TIDS%,[TIMEID],TIME,ID=%TIME_SET%)
*SELECT(%TIDPREVINCL%,[TIMEID],TIME,TIMEID<=%TIDS% AND YEAR=%Y% AND CALC=N)
*SELECT(%TNEXTINCL%,[ID],TIME,TIMEID>=%TIDPREVINCL% AND YEAR=%Y% AND CALC=N)
*XDIM_MEMBERSET TIME = %TNEXTINCL% //periods starting from the earliest till the end of the year
*XDIM_MEMBERSET MEASURES=YTD
*DESTINATION_APP = CONSOL
*WHEN DATATYPE
*IS ACTUAL //only in case of ACTUAL data
*WHEN ACCOUNT.ACCTYPE
*IS INC,EXP //P&L accounts
*REC(FACTOR = 1)
*ENDWHEN
*ENDWHEN
Example:
Data uploaded for 2016.02, 2016.04, 2016.05
%TNEXTINCL% will be 2016.02,2016.03,2016.04,2016.05,2016.06,2016.07,2016.08,2016.09,2016.10,2016.11,2016.12
Correct YTD values for all this months will be recalculated
2016.01 YTD will be unchanged.
Vadim