This is so interesting that Tableau is making different assumptions based on mark type. I hope a Tableau rep will chime in.
I was interested to find for one of these cases that if I show the crosstab in more of a table form, where the table calc will compute the YoY Change "at the lowest level, restarting every Day-Align", we can see that it does compute the % change from 2018. Which makes more sense to me than what the line chart is doing, actually. The table calculation would be operating on the previous row's year that is actually in the data set and available to the table calculation rather than the absolute prior calendar year. Maybe a line chart is smart enough to know that time series is being trended and to look for the last calendar year while the shape chart won't make that assumption?
I don't know. But, you can explicitly handle this: Modify your calculation to explicitly return null if the prior year in the data is not one actual calendar year prior, so something like:
IF LOOKUP(MAX([year]),-1) = MAX([year]) - 1
THEN (sum([Sales]) - lookup(sum([Sales]),-1)) / abs(lookup(sum([Sales]),-1))
Table Calcs do sometimes produce odd values based on the mark type -- see also: https://www.thedataschool.co.uk/damiana-spadafora/data-densification-demystified/
Thanks, Matt. I'll check that out.
Thank you Jennifer! The explicit handling makes sense.