2 Replies Latest reply on Nov 19, 2018 4:24 AM by Nino Chikovani

    Create a Calculated field

    Nino  Chikovani

      Hello everyone,

       

      I have a data - the sample data is attached- where are given individuals. Each individual has got different residence permits or citizenship and we have also an information about their in cross and out cross dates. As you see because of different reasons I have such data where I have duplicated data on each person. but my aim is to calculate how long each person stayed in that country. So I calculated datediff('day', [incrossdate] , [outcross date]), but as you see some of the individuals have entered the country border for several times that's why they may have different length of visit. So my next step was to calculate the sum of the length of visit but as my data is duplicated in some cases I get wrong results. I mean for example one person has one in cross date and one out cross date but because of the other information, I have several records in my data about this person. So when I calculate the length of visit, it is written for several times in my data and when I sum  the length of visit for each person it counts that length of visit for several time.

       

      E.g. For individual C : He has two in cross dates and out cross dates but is written for 4 times because of the additional information about him/her. When he visited first he stayed for 399 days and when he visited again he stayed for 1860 days but both of them are written twice. When I want to calculate the total length he stayed in my country I want to be calculated 399 + 1860 but tableau calculated 399+399+1860+1860 as both of them are written twice in the data for this individual.

       

      Could you please help me how to do it using a calculated field?

       

      Thank you in advance,

       

      Sincerely,

       

      Nino