2 Replies Latest reply on Feb 1, 2017 10:20 AM by Joe Oppelt

    Month over month Calculation

    Nagarjun Srinivas

      Hi all,

      I am new to tableau,

      I need to calculate % difference between sales for every month across all the states in united states and need to have a month filter so that a particular month can be selected. 

      I did a quick table calculation for calculating the % difference.  However, i need to select min two months in the filter to get the % difference.


      the result I am trying to achieve is when I select a particular month in the filter, I should be able to get the % difference between the selected month and the previous month.

      for example, I need to select January in the filter and I should be able to get the % difference between January and December(last year) without having to select both January and December months in the filter. In other words, the filter should be single select.


      I am attaching the workbook, Please let me know any possible ways to perform this task


      Thanks in advance

        • 1. Re: Month over month Calculation
          Vincent Baumel

          In order to calculate a difference, Tableau needs 2 data points. If you're filtering one of those data points out, then it can't possibly calculate a percent difference. It's a little tricky given the dataset you've provided (only having 2 months), so would it be possible to add a few more months onto the sample data so that we could choose a month in the middle and try to only show % difference for that specific month?  If you're curious, here's where I've got it so far:


          • 2. Re: Month over month Calculation
            Joe Oppelt

            When you use a quick filter, it eliminates rows from the table underlying the sheet.  So when you select January, all of December is deleted from the table, and, as you have seen, there is no December data for the LOOKUP to grab for the %Diff calc.


            But if you use a table calc for your filter, the filter hides/shows what you want without eliminating the other rows from the table.


            Table calcs are things like WINDOW_SUM, LOOKUP, RANK, INDEX, and 100 other things.


            I used LOOKUP to hack up a filter you can use.  It has its problems in its current form, because it will display the values alphabetically instead of in calendar order, I think.  (I may be wrong.  You'll need more data to validate this.)


            If that's the case, you could make a parameter that has the values in the proper order.  That would create a single-select entity for you to select a month too.