Reputation: 1803
I am attempting to write a case statement in tableau. I am casing the date field where I want to control for a specific date range.
CASE [Date] WHEN [Date] >= DATETIME('1/1/17') and [Date] < DATETIME('1/11/17') THEN 1 ELSE 0 END
However, I am getting a error - "Expected type data, found boolean. Compare in case must be date type.
I got the same error using: DATEPARSE('mm dd yyyy','1/1/17')
I understand my error. However, I can't seem to identify the function which convert my string into a date.
This post didn't help either. How to convert string to date format in Tableau
Anyone know?
Upvotes: 0
Views: 2989
Reputation: 1803
Looks like this works
sum(if year([Date]) == 2017 and MONTH([Date]) == 1 then [profit] END)
I'd still like to see the case solution if anyone can figure it out.
Upvotes: 0