13 Replies Latest reply on Jul 12, 2019 12:29 AM by Kat K Branched to a new discussion.

    Older/Newer Button for Dates

    Kat K

      Hi! I don't have a Tableau workbook yet since I'm not sure how to do it, but I haven't been able to find anything online from my research. Basically, I'm wondering if it's possible to do the following:


      I want to present some metrics about data from specific date ranges for when promotions are running (e.g. let's say July 5-8). I want to create buttons that allow you to navigate to the previous and the next promotion dates and see all the other metrics. For example, the current page shows metrics for July 5-8. Clicking the "older" button would show the same metrics for the previous promotion that took place June 25-28. From there, clicking the "newer" button would take you back to the metrics for July 5-8, while clicking the "older" button would take you to the metrics for (for example) June 16-21.


      Any guidance is much appreciated as I haven't been able to find any resources online!



      EDIT: attached a mock-up sample. As you can see, each date has a unique ID, which increases (without pattern) the more recent the date. You can tell which dates are part of which promo, as all the days are back-to-back, and there are gaps of at least one day in between promos. Promos are also numbered - the bigger the number, the more recent the promo, but there is again, no pattern to the promo number. I also know how many days each promo is scheduled for.


      As shown in the workbook, I'm trying to display sales by day for each promo; I want buttons that can go between each promo. I'd also like to include an average sales over the duration of that particular promo and how that compared to the previous (and maybe next) promo, but I'm not sure how to do that. Beginner to Tableau!

        • 1. Re: Older/Newer Button for Dates
          Naveen B

          Hi Kat,


          You can use actions Or parameters to get this O/P


          could you please attach sample data in twbx format to help you further




          • 2. Re: Older/Newer Button for Dates
            Kat K

            Unfortunately I'm not able to post, as it's client data - as a super simple example, say I had three promotions that ran as follows:


            Jun 19-21, Jun 25-28, Jul 5-6


            I have the company sales on each day, so I want to display the sales for each day as well as the average sales across the period. I could have:


            Jun 25 - 200k

            Jun 26 - 100k

            Jun 27 - 200k

            Jun 28 - 100k

            Avg: 150k (+25% previous period) <- compares to Jun 19-21


            I want a back button that brings me to:

            Jun 19 - 120k

            Jun 20 - 130k

            Jun 21 - 110k

            Avg: 120k (need at least two periods for % change)


            And a forward button that brings me to:

            Jul 5: 100k

            Jul 6: 90k

            Avg: 95k (-37% previous period) <- compares to Jun 25-28


            Just something like that!

            • 3. Re: Older/Newer Button for Dates
              Joe Oppelt

              Video demonstrates how to anonymize your workbook/data


              Part of what helps in having a workbook is seeing what the data layout looks like.


              How do you know that event-1 starts on date-A, and event-2 starts on date-B?  And how do you know how long each event lasts?   Your data (or a mocked-up sample) helps us get the look-and-feel of what that looks like and how it should be handled programmatically.


              Maybe there is an additional field called [Event name] that lets us derive start-end dates.  (If not, that would help you if you can get it added to the data.)


              I would be driving what you described using a parameter.  Maybe I know what event I'm currently looking at.  If the param is set to "newer" and therefore my calc will grab the data from event+1.  (Ditto "older".)


              If you are on 2019.2, you can drive it with a parameter action.  Let the user select the event to view, rather than play with "newer" and "older".

              • 4. Re: Older/Newer Button for Dates
                Kat K

                Some good points - I've revised the initial post to answer these questions and added a very simle mock-up of the workbook as well as the excel data.

                • 5. Re: Older/Newer Button for Dates
                  Joe Oppelt

                  What version of Tableau will you be using?

                  • 6. Re: Older/Newer Button for Dates
                    Kat K


                    • 7. Re: Older/Newer Button for Dates
                      Joe Oppelt

                      In the attached I made some simple beginnings.


                      On Sheet 2 I display all the promos.  I made calcs to derive start and end dates for each, and displayed them.  I also display all dates within each promo.


                      On sheet 2(2) I added a parameter that is populated by the [Promo Item] field.  And I made a filter to obey the parameter.


                      This is just a start.


                      I saved it as version 10.5.  It will upgrade to whatever version you are using.


                      If you are on 2019.2, there is a new Parameter action feature you can leverage too.

                      1 of 1 people found this helpful
                      • 8. Re: Older/Newer Button for Dates
                        Joe Oppelt

                        So on 2018.3 you won't have the parameter action feature, but this is a start.  It's one way to approach what you need to do.  Is it so important that you have the "older/newer" concept in there?


                        And that parameter can actually be sing the Promo Num field instead, if a numerical promo navigation is the preferred approach.  Same concept.

                        • 9. Re: Older/Newer Button for Dates
                          Kat K

                          Hm, thank you - I think it's a good start and I'll play around more with it. The thing is that this sample is extremely simple, but I'm hoping to build out a full dashboard with a lot of metrics, which is why I want to be able to display just the one promo group. The most important part is comparison between the previous promo and the current one (and maybe eventually a comparison of the current one to averages of all the promos to date). Trying to make an interactive dashboard where people can quickly flip between different promos and see all the metrics and comparison.

                          • 10. Re: Older/Newer Button for Dates
                            Kat K

                            I'm quite (basically brand) new to Tableau, would you also be able to help guide how to build out the dashboard so that it can flip between filtering for different promos?

                            • 11. Re: Older/Newer Button for Dates
                              Joe Oppelt

                              Kat -- In the attached I made some changes.


                              Edit the [Promo] parameter.  You will see that I changed it to an integer parameter, populated with the promo numbers rather than the promo names.  But also notice that I gave it display values of the promo names.


                              I think for the user, the promo names will be more meaningful than raw numbers.  And Tableau gives us the capability to have display values that are a different data type than the actual internal parameter values.  (And using numbers as the internal value is important to me later in the process.


                              So on Sheet 2 I show all data, including the promo numbers.  And I put that sheet on Dashboard 1 just to display all data for now.


                              On Sheet 2(2) I made a new parameter.  {Compare to:] has two values.  Older and Newer.  I used that to determine which promo number to grab for comparison. Since your promo numbers are not perfectly sequential, I can't just subtract 1 or add 1 to the selected promo from the user.


                              Take a look at the calc [Promo to compare] in the dimensions list.  Here I used a feature called LOD to grab the promo number that is next in line, either forward or backward depending on what the user selected.  If "older" then grab the max promo number that is less than the value from the [Promo] parameter.  Else do the opposite for values greater than the [Promo] value.  Note that this expects the [Promo Num] values to be increasing (not necessarily sequentially) down the promo list.  So if the promo with the newest Start Date actually had a promo number that was LESS THAN the promo that started before it, what I did here will not work properly.


                              Note also that your [Promo Num] data could actually be alpha-numeric values, and this would still work as long as each new promo is an increasing sequential value alphabetically.  (So "G45B, followed by "G45D".)


                              Anyway, play with the two params on Sheet 2(2).  See how the [Promo to compare] value changes.  Note that if you pick the last promo and also pick "Newer", tableau returns NULL for the compare value because there is nothing newer.


                              Now look at sheet 2(3).  I made a filter calc to grab the two promos represented by the [Promo] parameter, and by the [Promo to Compare] calc.  I have placed both Sheet 2 (which displays everything unfiltered) and Sheet 2(3) (filtered) on the dashboard.  Now you can see all the data for comparison purposes, and the two (or only one depending on param settings) promos that the user wants to see.

                              1 of 1 people found this helpful
                              • 12. Re: Older/Newer Button for Dates
                                Kat K

                                Appreciate the help Joe, thanks very much!

                                • 13. Re: Older/Newer Button for Dates
                                  Joe Oppelt

                                  Kat -- Just reply back here if you have questions.  There is a lot in there to absorb on the first pass.  Always glad to help out!