4 Replies Latest reply on May 23, 2016 4:02 AM by khalid norat

    how to add 2 months

    Mark McClure

      Hi - I'm relatively new to Tableau.

      If I want to add the totals of 2 months together how do I do this ?

      For example I want to be able to show the yearly totals broken down into 2 month blocks rather than monthly or quarterly.

       

      Also, if I want to breakdown a year into weeks, showing the difference week on week can this be done ?

       

      Any ideas would be appreciated

      Many thanks

        • 1. Re: how to add 2 months
          khalid norat

          If month([Date Field]) <=2 then  'Jan-Feb'

          elseif month([Date Field]) <=4 then 'Mar-April'

          elseif month([Date Field]) <=6 then 'May-Jun'

          elseif month([Date Field]) <=8 then 'Jul-Aug'

          elseif month([Date Field]) <=10 then Sep-Oct'

          elseif month([Date Field]) <= 12 then 'Nov-Dec'

           

          end

           

          This will give you your 2 monthly buckets

          You can use this and with the year of the date as columns to give you the data you require

           

          Please let me know if you need further assistance

          1 of 1 people found this helpful
          • 2. Re: how to add 2 months
            khalid norat

            Once you drag your date to the column or row shelf you can click on the down arrow and turn the date to weeknumber to be able to show data by weeks.

            1 of 1 people found this helpful
            • 3. Re: how to add 2 months
              Simon Runc

              hi Mark,

               

              So there are several way to go about this (as always in Tableau), and the options you have been given (Using Datepart and then an IF statement will do the trick)...as a alternative, you could use the Bin functionality.

               

              In the attached I've created a calculated field to extract the Month number (1-12), and then Binned these values, using a Bin size of 2 (as bins start from 1, I had to remove 1 from the month number to get the 1-2, 2-3...etc. Bins

               

              [Order Date - Month Part]

              DATEPART('month',[Order Date])-1

               

              and then I create a bin for this field

               

              as you can see we now have a dimension for every 2 months. The advantage of this, is we could set the Bin size off a parameter and so the user could choose if they want to see the data in 1, 2, 3,,,etc, month blocks? (btw you'd need to restrict the parameter, allowable, values t multiples of 12!)

               

              On the Week on Week, the Quick Table calc can do this...bring your Years and Weeks into the Viz, and then (in my example) sales as the values. The use the Quick Table Calc, and select Percentage difference.

               

              Hope that helps, but please post back if it doesn't make sense.

              2 of 2 people found this helpful
              • 4. Re: how to add 2 months
                khalid norat

                Hey Marc,

                 

                Simon Runc s method is the best way to do it.

                 

                what I sent you is the quick and dirty way but if you are building this for a project with changing requirements definitely look at those bins with parameters.

                 

                Using this method you could also put the weeks into bins.

                 

                Please don't forget to mark the answer as correct to help other forum users.