title: how to check if value exists in previous date and not in current date
body: <p>Below is my table and has id's, dates columns</p>
  
  <pre><code>ID      Date
  1       2017-06-11
  2       2017-06-11
  3       2017-06-04
  1       2017-06-04
  4       2017-06-04
  5       2017-06-04
  6       2017-05-28
  5       2017-06-04
  </code></pre>
  
  <p>2017-06-11 is this week beginning date and 2017-06-04 is last week beginning date.
   I want to create a flag where an Id exists in previous week and not in this week as 1. </p>
  
  <p>for example, ID 4 is present in previous week and not in this week.similarly ID 6 is present in 2017-05-28 and not in 2017-06-04.
  When I query/analyse my data in this week then my data should look like</p>
  
  <pre><code>ID      Date                 flag
  1       2017-06-11           0
  2       2017-06-11           0
  3       2017-06-04           0
  1       2017-06-04           0 
  4       2017-06-04           1 
  5       2017-06-04           0
  </code></pre>
  
  <p>Similarly when I analyse my data for previous week,</p>
  
  <pre><code>ID      Date              flag
  3       2017-06-04        0   
  1       2017-06-04        0   
  4       2017-06-04        0    
  5       2017-06-04        0
  6       2017-05-28        1
  5       2017-06-04        0
  </code></pre>
  
  <p>I tried with Left join to check Id's present in current date and not in previous date , however i get inaccurate data because this has to be dynamic. 
  When I query each week, I have to compare this week and previous week only and when I query last week, I have to get last week and 2017-05-28 data only.</p>
  
  <p>Then I give filter in tableau to select the date and display the result.</p>
  
  <p>Can anyone help me how to solve this problem?</p>