3 Replies Latest reply on Oct 11, 2017 1:13 PM by Bob Kraft

    Index Table Calculation

    Bob Kraft

      I am new to Tableau. I am working through the online tutorials, books, and courses.  I have simple problem that I am trying to solve in Tableau.  I would like to Index records along a row.  At first, I thought this would be a trivial task but after trying a variety of Table Calculation and LOD calculations.  I am stumped.   I have attached a workbook to illustrate my problem.  I have two dimensions (patientvisit_id, entry). I have one measure (duration). 


      PatientVisit_ID      Entry     Duration

      A                             1              10

      A                             2              20

      A                             3              30

      A                             4              40

      B                             1              10

      B                             2              20

      B                             3              30

      C                             1              10

      C                             2              20


      I would like to know how to create a cross tab that has an index of the patients displayed.    If I put Entry on the Columns shelf, PatientVisit_ID on the Row shelf, and Duration on the Marks shelf as Label.  I create a Calculated Field called Index with the Index() as the Calculation. Table calculation is Table Down.  I put this on the Row shelf after the PatientVisit ID. When I make PatientVisit_ID and Entry Discrete my table looks like this


      PatientVisit_Id      Index

      A                             1

      B                             2

      C                             3


      with multiple columns showing the duration at various Entries. This is exactly what I want except that Entry must be continuous.  When you change the Entry to continuous the table now the rows look like this


      PatientVisit_Id      Index

      A                            1

      B                            2

      C                            1



      I have created a workbook to illustrate this behavior.  All you have to do is change the Entry in the Columns shelf from Discrete to Continuous to see the problem as I have described it above.

      I am hoping that someone will be able to explain why the rows are displayed like this when Entry is set to Continuous.  I am also hoping that someone will be able to show me how to index my PatientVisit_Id properly. 


      This is just a toy example I worked up to illustrate the problem.  The real problem I am try to solve is display my PatientVisit_Ids one per row in a Gantt chart.  There are multiple bars for each patientvisit_id in my Gantt chart. As a result, there are multiple entries (Entry, which is a datetime field) for each patientvisit_id.  The actual patientvisit_ids are irrelevant to the people viewing the Viz, however, seeing an index of the number of rows in my Gantt chart would be useful.


      Any help, suggestions, or a solution to my problem is greatly appreciated.


      Thank you in advance.



        • 1. Re: Index Table Calculation
          Norbert Maijoor

          Hi Bob,


          Not sure but find my approach as reference below and stored in attached workbook version 10.1 located in the original thread.



          1. Define calculated field index: index() and drag object to the right of  Entry on the Rows Shelft


          2. Set index to discrete and drag the object between PatientVisit ID and Entry



          4. Index > textmenu > Compute Usng Entry



          5. "un-tick" Show Header for the object entry



          6. Drag calculated field Duration on Size on the marks card





          • 2. Re: Index Table Calculation
            Jim Dehner

            Hi Bob

            I'm not certain what you are trying to accomlish - I was going down the same track as Norbert so please look at his response

            Also there is a very good artical on Index() that may be helpful

            see the link At the Level – Unlocking the Mystery Part 1: Ordinal Calcs | Drawing with Numbers




            Let me know if this helps

            • 3. Re: Index Table Calculation
              Bob Kraft

              Norbert and Jim,


              Thanks for looking into my problem.  Jim I appreciate the link. Unfortunately,  I am still unable to accomplish my goal. I am trying to count and display the number of patients included in my Viz.  I have created a new workbook with three worksheets and a dashboard illustrating my problem. I think it comes down to trying to use Index() with a continuous dimension.  I believe the new workbook will do a better job of explaining my problem.

              Thanks again for all your help.  It experienced Tableau users like yourselves that allow the new guys to improve our skills.