I will the example of our Global super store data set, you can write some thing like
YTD: If datediff('year',[Order Date],today()) = 0 THEN [Sales] else 0 END
PYTD: If datediff('year',[Order Date],today()) = 1 AND [Order Date] < DATEADD('year',-1,today()) THEN [Sales] else 0 END
Let me know if this helps, please replace the order date with the date field in your data set.
Can you please elaborate your second question by giving an example of what you want to achieve.