-
1. Re: Using Parameter Values to define Date Range shown on Graph
Walt Reed Jan 4, 2017 10:57 AM (in response to stephen.desmond)Hey Stephen,
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?
Walt
-
2. Re: Using Parameter Values to define Date Range shown on Graph
Jeffrey Kritzman Jan 4, 2017 11:08 AM (in response to stephen.desmond)What is the syntax error? That would help us diagnose. Also, including the workbook would be helpful.
-
3. Re: Using Parameter Values to define Date Range shown on Graph
stephen.desmond Jan 4, 2017 11:11 AM (in response to Walt Reed)Hi Walt,
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'
ELSE NULL
END
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.
-
4. Re: Using Parameter Values to define Date Range shown on Graph
stephen.desmond Jan 4, 2017 11:13 AM (in response to Jeffrey Kritzman)Hi,
The error I receive is the following: cant compare datetime and string values
Thanks.
-
5. Re: Using Parameter Values to define Date Range shown on Graph
Jeffrey Kritzman Jan 4, 2017 11:16 AM (in response to stephen.desmond)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
ELSE NULL
END
-
6. Re: Using Parameter Values to define Date Range shown on Graph
stephen.desmond Jan 4, 2017 11:44 AM (in response to Jeffrey Kritzman)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?
Thanks
-
7. Re: Using Parameter Values to define Date Range shown on Graph
Jeffrey Kritzman Jan 4, 2017 11:51 AM (in response to stephen.desmond)Hi Stephen,
For the calculated field, try this:
DATE("12/12/16")
-
8. Re: Using Parameter Values to define Date Range shown on Graph
stephen.desmond Jan 4, 2017 11:57 AM (in response to Jeffrey Kritzman)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.
-
9. Re: Using Parameter Values to define Date Range shown on Graph
Jeffrey Kritzman Jan 4, 2017 12:08 PM (in response to stephen.desmond)2 of 2 people found this helpfulIf 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
Sales
ELSE NULL
END
ELSEIF [p.GEO]='DE' AND [p.Product]='BluRay' THEN
IF [Calendar Day]>=dateVariable2 THEN
Sales
ELSE NULL
END
ELSE Sales
END
Note - the indentation isn't necessary, but it helps make it more readable.
-
10. Re: Using Parameter Values to define Date Range shown on Graph
stephen.desmond Jan 5, 2017 9:30 AM (in response to Jeffrey Kritzman)1 of 1 people found this helpfulThanks 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]
END