4 Replies Latest reply on May 28, 2014 5:50 AM by Kiran v

    Percent difference calculation in a line graph view

    Kiran v

      Hi Tableau Users,

       

      How do I perform a table calculation in this view where I can see percent difference from the Base rate. For example on April 1,2013 if my base price was $120 what is the percent difference between ABD10 to Base.

       

      April 1,2013- BASE= $121

      April 1,2013- ABD10= $51

      Percent difference from BASE= -58%

       

      Ideally i would like to see -58% in the view.

       

      Any help is greatly appreciated.

       

      Thanks much.

        • 1. Re: Percent difference calculation in a line graph view
          Michel Caissie

          Kiran,

           

          have a look in the attachment, specifically the calculated fields

          ABD10 diff from Base

          BCD20 diff from Base

          CBD30 diff from Base

          and Label.

           

          On the green Label pill (with the little triangle) make a special attention to the  Edit Table Calculation - Compute using Advanced section. Make sure to have the right setting for the three calculated field

           

          Michel

          • 2. Re: Percent difference calculation in a line graph view
            Kiran v

            Works wonders Michel, thanks a ton. It works

             

            Although I would prefer to know your logic behind applying three different table calculations and then using them as an attribute in different string calc. I kind of get why you used ZN, WINDOWS_SUM and ATTR but can't really see the big picture.

             

            But it works perfectly.

             

            Thanks Michele.

             

            Regards,

            K

            • 3. Re: Percent difference calculation in a line graph view
              Michel Caissie

              Kiran,

               

              A good way to start to resolve this type of problem is to first display all the dimensions and measures in discrete mode on the row shelf  as i did in the validation sheet.

               

              Then you start precising your questioning.

              Here , for every  group  of Month - Classes, you want  to get the ratio from one member of Classes with another member of Classes.

              Already here you can figure that you will need some table calculation that will compute for every  Month-Classes group and will restart every Month.

               

              Now to get the ratios , you need to classify for each group which Classes is BASE vs ABD10  etc,... this is done with if ATTR(Classes) = 'BASE' etc,...

              And you need to apply the Window_Sum  on the Price and not only the Sum  in order to be able to restart the computation for every Month.

               

              Now if you return to your final Viz, what you have is the Price along an axis and the Month along another axis  and one mark for every Classes for every Month. Those marks are connected , which gives you a line chart.

               

              Now what you want to do , is to overlay the result you got in the previous calculations on the marks of your line chart.

              This is the goal of the Case in  the calculated field [Label].  What it say is ' if the Mark is for the Classes ABD10 then apply the result of the  [ABD10 diff from base]  on the label of the mark, etc...

               

              Michel

              1 of 1 people found this helpful
              • 4. Re: Percent difference calculation in a line graph view
                Kiran v

                Super helpful breakdown, will help me put future complex table calculations in perspective.

                 

                Thanks Michel.