1 Reply Latest reply on Nov 9, 2012 7:31 AM by Mark Holtz

    How do I select only the latest instance of a record?

    Damon Stoddard

      I am doing some work on the manufacture of serialized product.  I am trying to count how many distinct serialized units have completed a given process step.  In some cases, a unit will have to be reworked and so it will show up in the same process step multiple times but with a unique date/time stamp.  I only want to count the serial number when it is associated with the maximum date for the given process step.  I think I can do this with Index, but I'm unfamiliar with how index works.

       

      I've attached a workbook, any assistance would be appreciated.

        • 1. Re: How do I select only the latest instance of a record?
          Mark Holtz

          Hi Damon,

           

          You could accomplish this using the table calculation LAST().

          It counts the number of records in the partition from the current record to the last record.

          So for a given (partition) of a Unit in a Process Step (stepA-unit1, stepA-unit2), you could create a calculated field like:

          IF LAST () = 0
          THEN 'Show'
          ELSE 'Filter'
          END
          Then, click on the "Default Table Calculation" to change the method by which the calculation will be conducted.  Compute using Date and the calculation will now calculate by the Date field for each partition created.

           

          I created a couple views for you to try to follow along. Table Calculations still give me trouble in Tableau, but are quite powerful.  The only thing is that for them to work, you must bring in all elements that comprise the necessary partition (block of the table) into the view.  So your Chart would not be able to utilize the table calc because that view has only one partition with all your data in it. The partition in this example needs UnitID and ProcessStep to compute.

           

          Hopefully this was more helpful than confusing!