1 Reply Latest reply on Feb 8, 2017 1:47 PM by Khang Pho

    Calculation Help

    Nina Royce

      Hi All,

       

      I am trying to perform a simple calculation ([sum of field A]-[sum of Field B])/ Field B, but tableau does not seem to perform it correctly.

      It calculates this part correct ([sum of field A]-[sum of Field B]), but doe not seem to work with dividing. Any thoughts?

       

       

        • 1. Re: Calculation Help
          Khang Pho

          Hi Nina,

           

          Based on your screenshot you are showing aggregated data.  The error you are most likely getting is you cannot mix aggregated and non-aggregated data in calculations.  You have a few options depending on the calculation you are trying to get.  You can aggregate all parts of the calculation

           

          (SUM([Actintlabcost]) - SUM([Estintlabcost])) / (SUM([Estintlabcost]))

           

          What this will do is that the aggregated data shown on your view then do the math i.e.

           

          External = ( 4,749,915 - 4,911,034) / (4,911,034)

          Internal = (5,924,362 - 6,118,081) / (6,118,081)

           

          If you are trying to get the difference then divide by each Estintlabcost at the row level then you'd have to do a level of detail calculation.

           

          ({FIXED [ExtInt] : SUM([Actintlabcost])} - {FIXED [ExtInt]:SUM([Estintlabcost]))} ) / SUM([Estintlabcost])

           

          Khang