Can You share sample workbook
Tableau doesn't have conditional formatting but there are ways to produce it. You can create a calc field that is ytd > pytd, then drag to colors and set green for true, red for false. Or, you could use a similar calc field that returns a string or empty string, then drag that calc to label as a conditional label.
As Nick mentons, you can use calculations for this. I believe the way you wrote it would work for a conditional colour.
Create an IF statement formula:
IF YTD >PYTD, then "Green"
YTD<PYTD, then RED
Then drag this formula into your colour calculations and format it accordingly.
I hope this helps, if does please mark it as helpful or correct so other users can refer to it.
Thank you so much Nick.
Thank you Parker.