1 Reply Latest reply on Nov 29, 2016 4:12 PM by Patrick A Van Der Hyde

    Subtract 2 columns in below scenario?

    sumesh behl

      Hi,

       

      I have a worksheet setup like below in the tableau.

       

      I want to subtract the 2 columns, which are set up like this:-

       

      1st Column: Year=2015, Month = September, Cycl_Code=20

      2nd Column: Year=2016, Month = September, Cycl_Code=20

       

      Any idea how 2 subtract these to columns to get the result in a new column.

       

      Thannks

        • 1. Re: Subtract 2 columns in below scenario?
          Patrick A Van Der Hyde

          Hello Sumesh,

           

          Select your two date columsn on the date view page and then select Pivot from the drop down menu that appears when you right click on the selected column headers.  You will then get three columns in the pivot output -

          Column 1 will have the letters - a, b, c,d, e,a, b,c,d,e

          Column 2 will have those two dates September, 2015 and September, 2016

          Column 3 will have pivot field values - the values from your 2 columns.

           

          The issue you have is that those second column values are going to be positive so we will need to take care of that.

          i do that with this calculation:

          if [Pivot Field Names]="Sep-15" then [Pivot Field Values] else -[Pivot Field Values] END

           

          The result workbook shows this in more detail with sheet 3 showing the result desired.

           

          I hope that helps.  Please note that the attached workbook is in v10.1. 

           

          Patrick