3 Replies Latest reply on Oct 13, 2019 3:52 PM by Timothy Hong

    Time as Dimension

    Timothy Hong

      Hello all,

      I'm working on #MakeoverMonday week42 and trying to figure out how to work with time... It's in dimension so when I do the chart like the below, X-axis doesn't show the time in a continuous way instead it is lining up individuals' time record. Hope you understand what I'm trying to say. If you don't, please, let me know.

       

      Screenshot 2019-10-13 at 16.28.20.png

        • 1. Re: Time as Dimension
          Ken Flerlage

          You'll want to first convert it to seconds by doing a bit of string parsing. Try this calculated field:

           

          Seconds

          // Convert time (string) to number of seconds.
          INT(SPLIT([Time], ":", 1)) * 3600 +
          INT(SPLIT([Time], ":", 2)) * 60 +
          INT(SPLIT([Time], ":", 3)) 
          

           

          If you want, you can modify that to then convert to hours:

           

          Hours

          // Hours
          [Seconds]/3600
          

           

          • 2. Re: Time as Dimension
            Michel Caissie

            Timothy,

             

            Because you have a discrete dimension on the Rows , Tableau builds a line chart for every discrete value of Time. And since each value appears only once you cant get a line.

            First  you will need to transform your discrete Time values in  Continues values.

            You can split your time dimensions using : as a delimiter (in the Dimension pane, right-click  Time and select Transform - Custom split).

            You now get three dimensions, one for the hour, one for the minute and one for the seconds.

            From this you can compute the hours as a continuous value

            (

                (INT( [hour] ) * 60 * 60 )

                +

                (INT( [minute] ) * 60)

                +

                INT( [second] )

            )

            /

            3600

             

            Next you will have to change the Year value from an Int to a Date using

            DATE( STR( [Year] ) +'-01-01' )

             

            Using this you can get a graph like this

             

            but there is a problem with 1982 because they were probably two competitions in that year and the times are Summed.

            I don't know how you want to manage that, but I replaced  hours  with

            {FIXED [Year],[Place],[Gender]: MIN([hours])}

             

            This way the graph will only use the lowest times of the two competitions  giving you the following graph.

             

             

             

            Michel

            • 3. Re: Time as Dimension
              Timothy Hong

              Thank you Ken, it works!