0
votes

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?

1
Assuming [date] is a properly recognised date, why not just use a filter? If you want to use literal dates you need to format them correctly. In your dateparse function the format string clearly doesn't match the date literal. That is why it won't work.matt_black

1 Answers

0
votes

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.