title: Is this the right method to calculate age from date of birth in Tableau when there are duplicate values?
body: <p>What I am trying to achieve is to calculate age from date of birth in tableau however, due to duplicate records, a user's age will be multiplied however many times it was duplicated. The data source is an SQL database.</p>
  
  <p><a href="https://i.stack.imgur.com/4a2AM.png" rel="nofollow noreferrer">This is the output when I use a regular DOB calculation</a></p>
  
  <p><a href="https://i.stack.imgur.com/4a2AM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4a2AM.png" alt="enter image description here"></a></p>
  
  <p>The year of both users are 1998 but admin's age is 76 years old. This is the calculated field that I used to get that output.</p>
  
  <p><code>IF [DOB]&gt;DATEADD('year',-DATEDIFF('year',[DOB],TODAY()),TODAY()) THEN
      DATEDIFF('year',[DOB],TODAY())-1
  ELSE
      DATEDIFF('year',[DOB],TODAY())
  END</code></p>
  
  <p>Due to multiple one to many relationships within the database, the record for admin is duplicated four times</p>
  
  <p><a href="https://i.stack.imgur.com/cliPL.png" rel="nofollow noreferrer">Example of data for admin user</a></p>
  
  <p><a href="https://i.stack.imgur.com/cliPL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cliPL.png" alt="enter image description here"></a></p>
  
  <p>I've tried using level of detail expression in other charts to remove the duplicate data. For this calculation, I've tried doing the same for this chart however, it did not work</p>
  
  <pre><code>{INCLUDE [Username]:COUNT(DATEDIFF('year', [DOB], TODAY()))}
  </code></pre>
  
  <p>Is this the correct method for solving this problem or am I going about this problem entirely wrong?</p>