1 2 Previous Next 18 Replies Latest reply on Sep 8, 2016 12:23 PM by Sedona Leza

    Restrict Max Years in view (range slider)

    Sedona Leza

      I have data for 15 years. The default view is 6 years. Right now, the user can increase/decrease the range from 1-15 years showing. I want the user to only be able to increase the range to 10 years, but to be able to move that maxed out range across all 15 years.

       

      I am currently using Tableau 9.3, but am in the process of installing 10.0 as I write this.

        • 1. Re: Restrict Max Years in view (range slider)
          Derrick Austin

          Hey Sedona,

           

          Would filtering the data from a datasource filter be a solution? If you do this, it is like the data only contains 10 years instead of 15.

          • 2. Re: Restrict Max Years in view (range slider)
            Andrew Watson

            You want the user to see a maximum of 10 years of data, but that 10 year subset can be taken from any of 15 years? For example you have data from 2000-2015. The user can see any maximum combo of 2000 - 2010, 2001 - 2011, 2002 - 2012, ..., 2005 - 2015?

             

            If this is the case you can use 2 parameters for the user to select:

             

            1. either the start year or end year

            2. the number of years

             

            Then base calculations from that to display the selected range.

             

            Apologies if I've misunderstood the request here.

            • 3. Re: Restrict Max Years in view (range slider)
              Sedona Leza

              Andrew, you understand my request perfectly! I want: "The user can see any

              maximum combo of 2000 - 2010, 2001 - 2011, 2002 - 2012, ..., 2005 - 2015?"

              I figured the solution would involve parameters, but I'm not very good at

              creating them from scratch. Do you have any suggestions as to how I can go

              about this?

               

              --

              Sedona Leza

               

              On Thu, Sep 1, 2016 at 12:33 PM, Andrew Watson <tableaucommunity@tableau.com

              • 4. Re: Restrict Max Years in view (range slider)
                praveen p

                Please see the below screenshots if this is what you are trying to achieve using parameter

                 

                 

                This can also be achieved using range of dates filter

                 

                 

                Attached sample workbook for your reference.

                • 5. Re: Restrict Max Years in view (range slider)
                  Andrew Watson

                  Sure Sedona. There are a few solutions, Praveen supplying one of them above.

                   

                  Another alternative is to create a parameter for the start year, integer is fine assuming only whole years should be selected, with all of your year values - i.e. 2000, 2001, etc.

                   

                  Create another parameter with the length of time, again as an integer. This will be a range from X (the minimum time span) to 10, your maximum.

                   

                  Create a calculated field to use these parameters, something like:

                   

                  DATETRUNC('year',[YourDateField]) >= MAKEDATE([Parameters].[StartYear],1,1) AND DATETRUNC('year',[YourDateField]) < DATEADD('year',[Parameters].[LengthOfTime],MAKEDATE([Parameters].[StartYear] + 1,1,1))

                   

                  What that is saying is to only return records where the date is greater than the beginning of the start year and the date is less than your start year +1 plus the time period.

                   

                  Put the calculated field to the filters shelf and set to true.

                   

                  Note you'll have to change the field and parameter names to match your actual names and please test it as I haven't, it was typed directly into the forum.

                  • 6. Re: Restrict Max Years in view (range slider)
                    Sedona Leza

                    @Praveen P.'s does not show years greater than 10 in the slider. I want user to be able to move maxed out slider along 15 years, but no longer be able to increase the range. I can't tell if your data has years beyond 2002-2012.

                     

                    Andrew, your calculated field only shows data on Null (not True/False). My Year data is only yyyy so it is an integer, and I feel like the range Length of Time Parameter is on the right track.

                    • 7. Re: Restrict Max Years in view (range slider)
                      Andrew Watson

                      Ok, just change the formula, should be even easier: [YearField] >= [Parameters].[StartYear] AND [YearField]) <= [YearField] + [Parameters].[LengthOfTime]

                       

                      This would show 2002 - 2012 inclusive, for example. Just make it < instead of <= if you prefer it would show 2002 - 2011 inclusive.

                      • 8. Re: Restrict Max Years in view (range slider)
                        Sedona Leza

                        Same issue as [YearField] >= [Parameters].[StartYear] AND [YearField]) <= [Parameters].[EndYear]

                         

                        maybe there could be a way for there to be a parameter for # of years showing and another for start year? The user would be able to choose between 3-10 years and the start year? This wouldn't be a range, however, and I do like the aesthetic of the range slider.Capture.PNGCapture.PNGCapture.PNGCapture.PNG

                        • 9. Re: Restrict Max Years in view (range slider)
                          Andrew Watson

                          "maybe there could be a way for there to be a parameter for # of years showing and another for start year?" - This is what I suggested

                           

                          [YearField] >= [Parameters].[StartYear] AND [YearField] <= [YearField] + [Parameters].[LengthOfTime]

                           

                          There are 2 different parameters referenced, both integers.

                           

                          I don't know the format of your YearField but you may also need to convert that to an integer - just wrap it in INT() if necessary.

                          • 10. Re: Restrict Max Years in view (range slider)
                            Sedona Leza

                            the above pictures are from that. The # means it is an int already right?

                            Capture.PNGCapture.PNGCapture.PNG

                            • 11. Re: Restrict Max Years in view (range slider)
                              Andrew Watson

                              Right, it's an integer. You should actually drag it up to make it a dimension - drag to the list of dimensions or right click it and convert to dimension. 

                               

                              Now I see it written in Tableau I see I also made a mistake. It should be [BeginTerm]>=[StartYear] AND [BeginTerm]<=[StartYear]+[LengthOfTime]

                               

                              I would also set up the StartYear as a range of values as well so they can't select things such as year 25.

                               

                              Fix those 3 things and you should be all good. Hopefully :-)

                              1 of 1 people found this helpful
                              • 12. Re: Restrict Max Years in view (range slider)
                                Sedona Leza

                                So close!!!! How does user select start year? It is stuck on default Start Year and Start Year isn't affected by Begin Term Range, so 2002-2009 shows 2002-2004 (less than 3-10 range which is Length of Time Parameter Range) because the earliest year is 1994. The Start Year parameter can't be put into the Filter shelf, so how to add that ?

                                • 13. Re: Restrict Max Years in view (range slider)
                                  Andrew Watson

                                  Click on the parameter and 'Show parameter control'. A parameter isn't a filter - the calculation we created earlier sits within the filters.

                                   

                                  Also remove your Date Term filter as it's not necessary

                                  1 of 1 people found this helpful
                                  • 14. Re: Restrict Max Years in view (range slider)
                                    Sedona Leza

                                    Ugh, sorry to be difficult. I really like the Number of Years in View Parameter control showing, but the Start Year one just has too many values sothe slider is hard to use. I really want to adjust the Start Year by moving the min thing on the Begin Term multi-value slider around, especially since some dashboards have years 94-09 while others have 00-15 or 01-16 depending on the cohort's entry into the university, so having the Only Relevant Values option in Filters is desirable.

                                    1 2 Previous Next