title: Case statement customer query
body: <p>I am new to tableau  parameters. I am trying to execute the following query but somehow it give me missing parenthesis error. </p>
  
  <pre><code>SELECT 
  
   CASE 
      WHEN &lt;Parameters.Timeframe&gt; = 'YTD'
      THEN TO_CHAR(to_date('01-JAN-' || to_char(sysdate, 'YYYY'), 'dd-mon-yyyy')) 
  
      WHEN &lt;Parameters.Timeframe&gt; = 'MTD'
      THEN TO_CHAR(TO_DATE('01-' || TO_CHAR(SYSDATE,'MON-YYYY'),'DD-MON-YYYY'))
  
      WHEN &lt;Parameters.Timeframe&gt; = 'QTD' and TO_CHAR(SYSDATE,'Q') = 1 
      THEN TO_CHAR(TO_DATE('01-01-' || TO_CHAR(SYSDATE,'YYYY'),'MM-DD-YYYY'))
  
      WHEN &lt;Parameters.Timeframe&gt; = 'QTD' and TO_CHAR(SYSDATE,'Q') = 2 
      THEN TO_CHAR(TO_DATE('04-01-' || TO_CHAR(SYSDATE,'YYYY'),'MM-DD-YYYY'))
  
      WHEN &lt;Parameters.Timeframe&gt; = 'QTD' and TO_CHAR(SYSDATE,'Q') = 3 
      THEN TO_CHAR(TO_DATE('07-01-' || TO_CHAR(SYSDATE,'YYYY'),'MM-DD-YYYY'))
  
      WHEN &lt;Parameters.Timeframe&gt; = 'QTD' and TO_CHAR(SYSDATE,'Q') = 4 
      THEN TO_CHAR(TO_DATE('10-01-' || TO_CHAR(SYSDATE,'YYYY'),'MM-DD-YYYY'))
  
      ELSE
      TO_CHAR(SYSDATE) 
      END as DATE_RANGE_START
  
      FROM table a
  
  where 
      a.created_date  &gt;= CASE 
      WHEN &lt;Parameters.Timeframe&gt; = 'YTD'
      THEN to_date('01-JAN-' || to_char(sysdate, 'YYYY'), 'dd-mon-yyyy') 
  
      WHEN &lt;Parameters.Timeframe&gt; = 'MTD'
      THEN TO_DATE('01-' || TO_CHAR(SYSDATE,'MON-YYYY'),'DD-MON-YYYY')
  
      WHEN &lt;Parameters.Timeframe&gt; = 'QTD' and TO_CHAR(SYSDATE,'Q') = 1 
      THEN TO_DATE('01-01-' || TO_CHAR(SYSDATE,'YYYY'),'MM-DD-YYYY')
  
      WHEN &lt;Parameters.Timeframe&gt; = 'QTD' and TO_CHAR(SYSDATE,'Q') = 2 
      THEN TO_DATE('04-01-' || TO_CHAR(SYSDATE,'YYYY'),'MM-DD-YYYY')
  
      WHEN &lt;Parameters.Timeframe&gt; = 'QTD' and TO_CHAR(SYSDATE,'Q') = 3 
      THEN TO_DATE('07-01-' || TO_CHAR(SYSDATE,'YYYY'),'MM-DD-YYYY')
  
      WHEN &lt;Parameters.Timeframe&gt; = 'QTD' and TO_CHAR(SYSDATE,'Q') = 4 
      THEN TO_DATE('10-01-' || TO_CHAR(SYSDATE,'YYYY'),'MM-DD-YYYY')
  
      ELSE
      SYSDATE 
          END 
  
  and a.created_date  &lt;= sysdate
  </code></pre>
  
  <p>How should I fix it </p>