0 Replies Latest reply on Apr 29, 2014 9:20 PM by Leonardo Faoro

    How to calculate days since in multiple tables

    Leonardo Faoro


      I am a new user, loving Tableau, but now I'm a bit stuck. I am analyzing clinical trial data. The data looks like this


      Table 1 - visit


      - subject

      - visit_name

      - visit_date


      Table 2 - labs


      - subject

      - lab_name

      - lab_value

      - lab_date


      Tables are linked by "subject"


      What I want to do is to calculate the study day (not date) when the lab was taken. In the "visit" table, the date for Day 0 would be defined when visit_name="Day0".


      So I am trying to calculate in order

      1) The day 0 for each patient (day_date)

      2) The lab day for each patient by subtracting day0_date from lab_date


      I calculate day 0 by creating a calculated field:

      if [visit_name]='Day0' THEN visit_date END


      But that only calculates that row for the row where the visit is Day0, and I can't use this for the other calculations...


      How can I do this ? Thanks in advance