I am working on creating a filter in Tableau that filters a certain kpi (e.g. product sales) based on the time frame after product launch.
So the categories to filter by would be:
- 4 weeks after product launch
- 12 weeks after product launch
- 26 weeks after product launch
- 52 weeks after product launch
- All time
So far I created a Parameter ‘Time after Launch’ with exactly these categories and I am a bit stuck on how to create the corresponding calculated field – I tried this in order to then pull it into my sales over time overview:
IF [Time after launch]=’4 Weeks after Launch’ then datediff(‘week’, [Date], [Launch Date])<=4
ELSEIF [Time after launch]=’12 Weeks after Launch’ then datediff(‘week’, [Date], [Launch Date])<=12
ELSEIF [Time after launch]=’26 Weeks after Launch’ then datediff(‘week’, [Date], [Launch Date])<=26
ELSEIF [Time after launch]=’52 Weeks after Launch’ then datediff(‘week’, [Date], [Launch Date])<=52
ELSEIF [Time after launch]=’All Time’ then [Date]
END
but obviously it does not work. Maybe I have to attach it directly to the sales?
Thanks for any help!
Michelle