1 Reply Latest reply on Oct 8, 2012 7:39 PM by Jonathan Drummey

    help with calculating %increase/decrease

    Clint Noll

      i am looking for some help with a beginners question.

       

      i have attached my workbook. i am wanting to add another column to this table that will show the % increase or decrease on a calculated field. (if that is the correct way)

       

      my data is

      trips, year, state, county

      the trips field is simply a integer i am summing

      the year is either 2011 or 2012

      state is just that

      and county is the different counties i am grouping by

       

      i have created a calculation

      if

      attr([year])= 2011

      then SUM([trips] )

      elseif

      attr([year])=2012

      then sum([trips])

      end

       

      which is giving me what i am looking for. but not sure how to add another field at the end that would calculate the difference between 2011 and 2012.

        • 1. Re: help with calculating %increase/decrease
          Jonathan Drummey

          Hi,

           

          Tableau makes your life even easier: Your calculated field is not necessary, and you can get the results you want in five mouse clicks.

           

          When you drag a measure pill into a view Tableau will automatically apply the measure's default aggregation (it starts out as SUM), and the computation will be performed in each cell in the view that is formed by the combination of discrete (blue) pills, which are usually (but not always) dimensions. So dragging trips into the view with county on Rows and year on Columns causes Tableau to calculate SUM(trips) for each combination of county & year.

           

          Then, you can click on the right end of the green SUM(trips) pill (or right-click on the pill) and choose Quick Table Calculation->Difference and Tableau will turn that SUM(trips) into a difference from prior table calculation. The default Compute Using for the pill is Table(Down), which computes based on the county, when what you want is the year, so you click once more on the pill to set the Compute Using to year.

           

          Jonathan