title: Calculate value based on existence of records matching given criteria - FileMaker Pro 13
body: <p>How can I write a calculation field in a table that outputs '1' if there are other (related) records in the same table that meet a given set of criteria and '0' otherwise?</p>
  
  <h2>Here's my problem explained in more detail:</h2>
  
  <p>I have a table containing 'students' and another containing 'exam results'. The 'exam results' table looks like this:</p>
  
  <pre><code>StudentID  SubjectID Level   Result
  3234       1         2       A-
  3234       2         4       B+
  4739       1         4       C+
  </code></pre>
  
  <p>A student can only pass a Level 4 exam in subject 2 if they have also passed a Level 2 exam in subject 1 with a B+ or higher. I want to define a field in the 'students' table that contains a '1' if there exists an exam result belonging to the right student that meets these criteria and a '0' otherwise.</p>
  
  <p>What would be the best way to do this?</p>