I got an answer by email I would like to share that shows a few more variations than just prior year:
You don’t have to use RawSQL to build these time-based-cohorts. You can use IF statements to bucket a given measures into whatever dynamic time period you want. For example:
Sales Last Year
If datediff(‘year’, [Date], today())=1 then [Sales] end
Sales This Year
If datediff(‘year’, [Date], today())=0 then [Sales] end
Sales rolling 90 days
If datediff(‘day’, [Date], today())<=90 then [Sales] end
Sales last 4 weeks
If datediff(‘week’, [Date], today())<=4 then [Sales] end
Sales Prior YTD
if datediff('year', [Date], today()) = 1 AND datediff('day', [Date], today())>=365 then [Sales] end
You can replace the condition with anything you want to act as a filter on a particular measure. You can then write other calculated fields from these guys to find % change and other calculations.
I am trying to implement the some thing similar in my workbook but I am lost. I am not sure where to start with. Can you please help.
I have attached the workbook and a desired graph which I am trying to achieve using Tableau. Would appreciate your time and effort in looking at the request.
Example.twbx.zip 373.9 KB