3 Replies Latest reply on Oct 10, 2016 6:53 AM by David Li

    Table Calculations

    Lavanya Doddi

      Hi there,

       

      Please see attached image for some dummy data and expected tableau output ..

       

       

      I am planning to calculate % sales using Table calculations.

       

      I am not sure how I am able to calculate the Impr. column using Tableau's table calculations. Any help is greatly appreciated.

       

      Thanks

        • 1. Re: Table Calculations
          David Li

          Hi Lavanya, here's what I would do:

          1. Create a table calculation for % of total sales. Set it to compute along Pre/Post (so that it only applies within each Category). Let's call this field [% Sales].

            SUM([Sales])/TOTAL(SUM([Sales]))

          2. Create a calculated field that gets the Impr. field and add it to the view.

            [% Sales] * 2 - 1

          3. Hide all but the highest value for Impr. per Category somehow. There are quite a few ways to do this, so let me know if you need more specifics. For instance, you could do a WINDOW_MAX() along [Pre/Post].
          • 2. Re: Table Calculations
            Lavanya Doddi

            Thanks for the response, David.

             

            Is there an easy way to write the formula for Impr. field. Its a very simple formula: [Post - Pre].

            In the example above, for Cat1, 83.3% - 16.7% = 66.7%

            • 3. Re: Table Calculations
              David Li

              The second formula is the Impr. formula.

              [% Sales] * 2 - 1

              If you look at the table you have above, you see that the expanded formula for Impr. is

              %Sales - (1 - %Sales)

              This simplifies to

              % Sales * 2 - 1

              For example:

              83.3% - 16.7%

              83.3% - (1 - 83.3%)

              2 * 83.3% - 1