2 Replies Latest reply on Oct 2, 2017 10:31 AM by Clayton Johanson

    Conditional Filtering Specific Dates

    Clayton Johanson

      First time question on the forums.

       

      I am working with performance data on trains. I have attached with packaged workbook with sample data for a two week period. I am trying to find out the relationship between late trains. I have a parameter control to select a specific train symbol. I then want to find that on days where the status of the selected train is 'LATE', I want the sum of the 'LATE' status for all the other trains.

       

      In the sample data train 1200 is late on four days. Of those four days train 1206 was late three times and train 1208 was late twice.

       

      I have a tried a number of different filtering routes, but not getting exactly what I want.

        • 1. Re: Conditional Filtering
          Chris Geatch

          Hello, and welcome to the forums.  I've made the assumption that you are trying to display a train number, and the total number of other trains that were late.  If that's not the case, then let us know.  However, maybe this will still be useful.

           

          I've re-used your dimension to use as a filter.  "Train Number Selector" now filters the train number based on which of your parameter values is selected.

          I've created a new variable, "Tran Was Late", to separate out the late trains from the on time trains.  You could count them in one step, but I always end up wanting to do things later that need me to create a separate dimension anyway.

           

          I've dragged both of those items to the filter box, set True for the late indicator, and True for the Train selector.

           

          There's one more measure I've created, where it allocates a 1 to each train that is "Train Was Late", and where the train number is not the same as the one selected in the parameter.  The FIXED part of that formula tells it to ignore any other filters.  FIXED is a Level Of Detail (LOD) function, and they are pretty fundamental to getting things done in Tableau.

           

          That's probably only part of what you want, so feel free to reply.

           

          The attached workbook is in version 10.1.3, hopefully you can open it.

          • 2. Re: Conditional Filtering
            Clayton Johanson

            That was better, but did not quite get me what I wanted.

             

            I thought about the problem more and I was thinking about it wrong. I really need to filter out specific dates based on the status of a train selected in the parameter control.

             

            For example: If the status of train 1200 on 10/1/16 is equal to 'LATE', then include that date, if the status was equal to 'OT', then exclude the date. Once I have excluded the dates where the train ran on time, I can then count the other late trains.