4 Replies Latest reply on Oct 9, 2018 3:10 AM by WILL THOMAS

    Work out age of item from build year

    WILL THOMAS

      I need to create a calculated field which will give me the age of the item in question.

       

      I already have the year the item was built as a dimension (build year). So clearly the age of the item is current year minus (build year).

       

      Please advise on how I can get this from Tableau.

       

      Thanks!

        • 1. Re: Work out age of item from build year
          Don Wise

          Hi Will,

          Not knowing the structure of your data nor the type of data (string vs date) makes it difficult for folks to respond.  Regardless, you could try the following:

           

          DATEPART('year',TODAY())-DATEPART('year',[Date])

           

          If it answers your question, please mark this response as correct.  Thx, Don

          • 3. Re: Work out age of item from build year
            WILL THOMAS

            Hi Nick. Thanks for your response.

             

            I am still having some trouble and have realised my initial question wasn't exactly what I need.

             

            I have created an example data set to try and explain better - see below.

             

            I want to create a chart which will show me the average age of the items in each policy year - that is, the age that the item was during that policy year.

             

            So For each policy, we need to subtract policy year by build year, then work out the average in each policy year. So in 2010, the average age would be 17.5 years old.

             

            Do you know how I can do this within tableau?

             

            Thanks!

            • 4. Re: Work out age of item from build year
              WILL THOMAS

              Hi Don. Thanks for your response.

               

              I am still having some trouble and have realised my initial question wasn't exactly what I need.

               

              I have created an example data set to try and explain better - see below.

               

              I want to create a chart which will show me the average age of the items in each policy year - that is, the age that the item was during that policy year.

               

              So For each policy, we need to subtract policy year by build year, then work out the average in each policy year. So in 2010, the average age would be 17.5 years old.

               

              Do you know how I can do this within tableau?

               

              Thanks!