title: Error in my Tableau calculated field for counting days
body: <p>I am trying to calculate the number of days for a project based on the active_flag.
  If the active flag is true, the number of days should be calculated from the end_day till today.
  If the active flag is false, the number of days should be calculated from the end_day till the last observation date (ob_date).  Below is my attempt: </p>
  
  <pre><code>if active_flag = True then datediff('day',[end_date],TODAY()) 
  elseif active_flag = False then datediff('day',[end_date], max([ob_date])) end
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/YjAY7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YjAY7.png" alt="calc window with errors"></a></p>
  
  <p>I see the errors so I'm looking for suggestions on how to re-write this calc to get the desired result.</p>