I'm not quite understanding your formula. Is Calendar Day or Date the parameter? It doesn't look like a parameter is being used...if it were, it would seem that the hard-coded date values of 12/12 and 12/25 would be replaced by parameters.
Do you have an example workbook you could share with us? If so, can you also include the version of Tableau that you're using?
What is the syntax error? That would help us diagnose. Also, including the workbook would be helpful.
Apologies, I made a typo, it should be the following:
IF[p.GEO]='UK' AND [p.Product]='DVD' THEN [Calendar Day]>='12/12/2016'
ELSEIF [p.GEO]='DE' AND [p.Product]='BluRay' THEN [Calendar Day]>='12/25/2016'
The parameters are the location p.GEO and product p.Product. Calendar day is day of the sales.
Essentially when I select either of those settings in the parameter, I just want the graph show from December 12th in the first case for UK with DVDs and from the 25th in the case with Germany and Blu Rays.
The SYNTAX error I receive is can't compare datetime and string values. Thanks.
The error I receive is the following: cant compare datetime and string values
Thanks, that helps. The issue is that you're comparing your date variable against a string. If you make two calculations or parameters (one each for 12/12/16 and one for 12/25/16) and make them dates, you will be able to do your calculation using them instead. I.e.
IF[p.GEO]='UK' AND [p.Product]='DVD' THEN [Calendar Day]>=dateVariable1
ELSEIF [p.GEO]='DE' AND [p.Product]='BluRay' THEN [Calendar Day]>=dateVariable2
I have created the date variables using a calculated field but I'm not sure I've done it correctly.
I have it set as [Calendar Day]=#12/12/2016# for example but when putting this into the overall formula I get an error: can't compare boolean and datetime values. Do I need to do anything else for the variable fields to be seen as dates?
For the calculated field, try this:
Thanks again. So that's solved the calculated fields issue. In the overall formula, I'm not getting an error that you "Cannot use Boolean type in IF expression".
Appreciate the help.
2 of 2 people found this helpful
If I'm correctly understanding what you want to do, try this. I'm assuming you want Sales to show up if it's not UK/DVD or DE/BluRay:
IF[p.GEO]='UK' AND [p.Product]='DVD' THEN
IF [Calendar Day]>=dateVariable1 THEN
ELSEIF [p.GEO]='DE' AND [p.Product]='BluRay' THEN
IF [Calendar Day]>=dateVariable2 THEN
Note - the indentation isn't necessary, but it helps make it more readable.
1 of 1 people found this helpful
Thanks all for the suggestions. I used this and it's worked perfectly:
[Calendar Day]>=IF [p.GEO]='UK' AND [p.Product]='DVD' THEN DATE('2016-12-12')
ELSEIF [p.GEO]='DE' AND [p.Product]='BluRay' THEN DATE('2016-12-12')
ELSE [Calendar Day]