You'll need a parameter to do this.
[Month selector] : String parameter type. Create the values as 1, 2, 3, 4, ..., 12 and change the display text to January, February, etc.
[YTD up to that month] :
DATEADD('month',1,DATEPARSE('yyyy-M',DATENAME('year',TODAY()) + "-" + [Month Selector]))
DATEPARSE: The parameter value is used to generate a date representing the first of that month. For example, January would be January 1, 2016. DATEADD: This offsets it by a month, allowing you to compare against the end of the month, not the beginning.
Same as previous calculation, but replace
DATENAME('year',TODAY())
with
STR(DATEPART('year',TODAY())-1)
Offsets the year by one.
[YTD Sales] - Calculate year to date.
IF [Date] < [YTD up to that month] AND DATEDIFF('year',[Date],[YTD up to that month])= 0 THEN [Measure1] END
[PYTD Sales] - Duplicate the previous calculation and change references of YTD to PYTD.
IF [Date] < [PYTD up to that month] AND DATEDIFF('year',[Date],[PYTD up to that month])= 0 THEN [Measure1] END
[YTD/PYTD filter]
MONTH([Date]) <= INT([Month Selector])
Make your visualization!