8 Replies Latest reply on Apr 24, 2017 8:45 AM by Walt Reed

    Last Week Sales

    Moin Khalid

      Hi,

      I am trying to get the last week sales for the selected week. but I am not sure how can I achieve this in tableau.

      I need to select week dynamically using filter and then select the last week sales to that selected week.

      Any help would be appreciated to resolve this.

       

      Thanks, Moin

        • 1. Re: Last Week Sales
          Vincent Baumel

          Try checking out the LOOKUP function and seeing how that works. Here's the description of how it works:

           

           

          I imagine you could use a filter or parameter to replace the integer in their example calculation. This would give your users the ability to check various values, while having them all be relatively equivalent (in this case, they would always get the value of the PRECEDING week to the one they've selected).

           

          If you still can't quite get it, let me know and we can write a calc up together.

          1 of 1 people found this helpful
          • 2. Re: Last Week Sales
            Moin Khalid

            As long as all the weeks are selected in the filter Lookup() works fine. If I apply a quick filter to get a particular week then in that case I am not able to get the lookup() function to work and get the last week sales information.

            • 3. Re: Last Week Sales
              Vincent Baumel

              I guess that makes sense. If you're using a quick filter to limit your data set, then the LOOKUP function will only have the remaining values to work with. I'll have to play around with getting the calculations right, unless someone else chimes in with an answer first!

              • 4. Re: Last Week Sales
                Vincent Baumel

                Got it, using a parameter! I created a parameter called Week Selection, which I set up like this:

                 

                From here, I created a calculation called Target Amount, that looks like this:

                What this does is say "whichever week you've selected with the parameter, display "Previous Month: " followed by the previous week's value". When the very first parameter choice is selected, it simply doesn't display anything (this is what the null refers to in the calculation).

                2 of 2 people found this helpful
                • 5. Re: Last Week Sales
                  Moin Khalid

                  Thanks for the response. Can this be achieved without the parameter. Because if I want to show only relevant weeks in my drop down then I have to use quick filter in that case. And my fiscal year can have total week different than 53 so in that case I want to use quick filter and see the sales for this week and a week prior to that.

                  • 6. Re: Last Week Sales
                    Vincent Baumel

                    Hmm. This one I'm not sure about. Selecting a year in a quick filter will cut your data set down to just that year, at which point finding a "previous week's value" is illogical since there are no previous weeks. I'm at a bit of a loss here, Moin. Perhaps someone else could help us out and we both could learn something new!

                    • 7. Re: Last Week Sales
                      Moin Khalid

                      Let me simplify the question. I want to see the last week sales of any week that is selected in the quick filter. If the week is changed then last week sales should also be changed in reference to that selected week.

                       

                      Quick filter is required as user only want to see the related week of the Year and Period selected in year and period filters.

                      1 of 1 people found this helpful
                      • 8. Re: Last Week Sales
                        Walt Reed

                        Hi Moin,

                        I'll chime in. My understanding (based on tackling this problem multiple times & in multiple ways) is that you need to use Parameters, Index and/or table calcs to achieve your desired outcome. Using the Quick Filter won't return a previous period's value since the data is technically filtered out of the view, whereas combining Parameter & INDEX (which I don't think was presented on this thread) will allow you to see the selected week, it's values, and last week's values (and the parameter can "look" like it's a quick filter).

                         

                        Walt