Not sur but just as an starter find my approach as reference below and stored in attached workbook version 10.2 located in the original thread.
1. M1. YTD: if year([Date])=year(today()) and [Date]<=today() then [Value] END
2. M2. MTD: if month([Date])=month(today()) and year([Date])=year([Date]) and [Date]<=today() then [Value] END
3. P1. P1 YTD, MTD
3. M3. YTD or MTD: if [YTD, MTD]='YTD' then [M1. YTD] elseif [YTD, MTD]='MTD' then [M2. MTD] end
Hope it helps,